fix: rollout controller cannot shrink bindings to zero when none are ready#588
Draft
Copilot wants to merge 3 commits into
Draft
fix: rollout controller cannot shrink bindings to zero when none are ready#588Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
When targetNumber is 0, determineBindingsToUpdate now unconditionally returns all removeCandidates, updateCandidates, and applyFailedUpdateCandidates for removal, bypassing the rolling update maxUnavailable constraints. This fixes the bug where stale bindings were never removed when scaling a placement down to zero clusters and no bindings were in a ready state. Also removes the TODO comment that tracked this bug and adds three table-driven unit tests covering the scale-to-zero cases. Agent-Logs-Url: https://github.com/kubefleet-dev/kubefleet/sessions/b12fc607-900f-4a0d-a4b8-217bf49c6725 Co-authored-by: ytimocin <5220939+ytimocin@users.noreply.github.com>
…gsToUpdate Agent-Logs-Url: https://github.com/kubefleet-dev/kubefleet/sessions/b12fc607-900f-4a0d-a4b8-217bf49c6725 Co-authored-by: ytimocin <5220939+ytimocin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix rollout controller to shrink to zero when bindings are not ready
fix: rollout controller cannot shrink bindings to zero when none are ready
Apr 8, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a placement's target is scaled to 0, stale bindings are never removed if no bindings have reached a ready state.
calculateMaxToRemovecomputesmaxNumberToRemove = len(readyBindings) - len(canBeUnavailableBindings) - minAvailableNumber, which is ≤ 0 when no bindings are ready — blocking all removals unconditionally.Changes
pkg/controllers/rollout/controller.go: Add a scale-to-zero fast path at the top ofdetermineBindingsToUpdate. WhentargetNumber == 0, allremoveCandidates,updateCandidates, andapplyFailedUpdateCandidatesare returned immediately, bypassing rolling update constraints (there is no minimum availability to preserve when targeting zero).pkg/controllers/rollout/controller_test.go: AddTestDetermineBindingsToUpdatewith three cases:targetNumber=0, no ready bindings → all candidates removedtargetNumber=0, some ready bindings + apply-failed candidates → all candidates removedtargetNumber>0, no ready bindings → rolling update constraints preserved (existing behavior)