mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 08:18:18 +00:00
fix(decommission): persist progress adaptively (#3497)
Persist decommission progress after either the existing time interval or a migrated-item threshold, and flush progress baselines after bucket and terminal-state saves. Also stabilize the OIDC discovery mock used by the pre-commit gate.
This commit is contained in:
@@ -2356,6 +2356,7 @@ impl ECStore {
|
||||
let mut pool_meta = self.pool_meta.write().await;
|
||||
if pool_meta.decommission_failed(idx) {
|
||||
pool_meta.save(self.pools.clone()).await?;
|
||||
pool_meta.mark_decommission_progress_saved();
|
||||
|
||||
drop(pool_meta);
|
||||
|
||||
@@ -2387,6 +2388,7 @@ impl ECStore {
|
||||
let mut pool_meta = self.pool_meta.write().await;
|
||||
if pool_meta.decommission_complete(idx) {
|
||||
pool_meta.save(self.pools.clone()).await?;
|
||||
pool_meta.mark_decommission_progress_saved();
|
||||
drop(pool_meta);
|
||||
if let Some(notification_sys) = get_global_notification_sys() {
|
||||
let stage = format!("complete_decommission for pool {idx}");
|
||||
@@ -2432,6 +2434,7 @@ impl ECStore {
|
||||
idx,
|
||||
bucket.name.as_str(),
|
||||
)?;
|
||||
pool_meta.mark_decommission_progress_saved();
|
||||
}
|
||||
}
|
||||
return Ok(());
|
||||
@@ -2459,6 +2462,7 @@ impl ECStore {
|
||||
idx,
|
||||
bucket.name.as_str(),
|
||||
)?;
|
||||
pool_meta.mark_decommission_progress_saved();
|
||||
}
|
||||
|
||||
warn!("decommission: decommission_pool bucket_done {}", &bucket.name);
|
||||
|
||||
+13
-4
@@ -1698,15 +1698,24 @@ mod tests {
|
||||
.expect("failed to set discovery mock stream blocking");
|
||||
|
||||
seen += 1;
|
||||
stream
|
||||
.set_nonblocking(false)
|
||||
.expect("failed to set discovery mock stream blocking");
|
||||
stream
|
||||
.set_read_timeout(Some(Duration::from_secs(1)))
|
||||
.expect("failed to set discovery mock read timeout");
|
||||
|
||||
let mut request_bytes = Vec::new();
|
||||
let mut buffer = [0u8; 4096];
|
||||
loop {
|
||||
let n = stream.read(&mut buffer).unwrap_or_default();
|
||||
if n == 0 {
|
||||
break;
|
||||
match stream.read(&mut buffer) {
|
||||
Ok(0) => break,
|
||||
Ok(n) => request_bytes.extend_from_slice(&buffer[..n]),
|
||||
Err(e) if matches!(e.kind(), std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut) => {
|
||||
break;
|
||||
}
|
||||
Err(_) => break,
|
||||
}
|
||||
request_bytes.extend_from_slice(&buffer[..n]);
|
||||
if request_bytes.windows(4).any(|w| w == b"\r\n\r\n") {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user