Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions release-notes/unreleased/requeue-on-active-drain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Release Notes: Requeue based on drain poll interval when old deployments are still active

## Bug Fix

### What Changed
When old deployment versions still have active invocations (draining), the
operator now requeues every 10 seconds instead of the hardcoded 5-minute
reconcile interval. This applies to both ReplicaSet and Knative deployment
modes.

### Why This Matters
Previously, even with `drainDelaySeconds: 0`, old versions could take up to
5 minutes to be cleaned up because the controller's default requeue interval
was always used when active invocations were still present. The drain delay
setting had no effect on how quickly the operator polled for drain completion.

### Impact on Users
- Cleanup of old versions now happens within ~10 seconds of drain completion
instead of up to 5 minutes
- No configuration changes needed

### Related Issues
- Follow-up to PR #96 (configurable drain delay)
11 changes: 11 additions & 0 deletions src/controllers/restatedeployment/reconcilers/knative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,17 @@ pub async fn cleanup_old_configurations(
}
}

// If there are active old deployments still draining but no removal is yet scheduled,
// requeue on a short poll interval to detect drain completion promptly.
if active_count > 0 && next_removal.is_none() {
let poll_seconds = 10;
next_removal = Some(
chrono::Utc::now()
.checked_add_signed(chrono::TimeDelta::seconds(poll_seconds))
.expect("next_removal in bounds"),
);
}

Ok((active_count, next_removal))
}

Expand Down
11 changes: 11 additions & 0 deletions src/controllers/restatedeployment/reconcilers/replicaset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,5 +402,16 @@ pub async fn cleanup_old_replicasets(
}
}

// If there are active old deployments still draining but no removal is yet scheduled,
// requeue on a short poll interval to detect drain completion promptly.
if active_count > 0 && next_removal.is_none() {
let poll_seconds = 10;
next_removal = Some(
chrono::Utc::now()
.checked_add_signed(chrono::TimeDelta::seconds(poll_seconds))
.expect("next_removal in bounds"),
);
}

Ok((active_count, next_removal))
}
Loading