Fix eviction overwriting failed migration condition with success#309
Conversation
When an eviction processes a list of VMs and one is in ERROR state, the controller correctly skips it via moveToBack and sets a Failed migration condition. However, the next successful migration of another VM unconditionally overwrote that condition with Succeeded, hiding the fact that an errored VM was still outstanding. Preserve the Failed condition while there are still outstanding VMs. The condition resolves naturally: either the errored VM is fixed and migrates (overwriting with Succeeded), or the eviction terminates with Evicting=Succeeded once the list empties. Adds a unit test covering a mixed list of healthy and errored VMs that exercises the skip-and-retry pattern across multiple reconciliations.
📝 WalkthroughWalkthroughThe eviction controller's migration condition handling now preserves "sticky" failure states. When an instance migration completes but other instances remain outstanding with a prior ChangesSticky migration failure condition
Sequence Diagram(s)(No sequence diagrams generated; the change is a single-layer conditional logic update with localized control flow rather than multi-component interactions requiring visualization.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/controller/eviction_controller_test.go`:
- Around line 592-597: The test currently only checks the error message when err
!= nil which lets a nil error slip by; change the assertions around
evictionReconciler.Reconcile(reconcileRequest) so you first assert that err is
not nil (e.g., Expect(err).ToNot(BeNil())) and then unconditionally assert the
error string contains the VM UUID (use
Expect(err.Error()).To(ContainSubstring("error-1"))), keeping references to
evictionReconciler.Reconcile, reconcileRequest and err to locate the code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b1e9da2a-6e5d-43d1-826b-f75af88c14db
📒 Files selected for processing (2)
internal/controller/eviction_controller.gointernal/controller/eviction_controller_test.go
When an eviction processes a list of VMs and one is in ERROR state, the
controller correctly skips it via moveToBack and sets a Failed migration
condition. However, the next successful migration of another VM
unconditionally overwrote that condition with Succeeded, hiding the fact
that an errored VM was still outstanding.
Preserve the Failed condition while there are still outstanding VMs.
The condition resolves naturally: either the errored VM is fixed and
migrates (overwriting with Succeeded), or the eviction terminates with
Evicting=Succeeded once the list empties.
Adds a unit test covering a mixed list of healthy and errored VMs that
exercises the skip-and-retry pattern across multiple reconciliations.
Summary by CodeRabbit
Bug Fixes
Tests