fix: capacity filter correctly accounts for multi-VM CR reservation slots#784
Conversation
📝 WalkthroughWalkthroughCapacity-filtering logic for committed reservations is rewritten to partition allocations into "confirmed" (present in both Spec and Status) and "spec-only" (Spec-only), computing remaining resources and blocking conservatively. Documentation expanded to cover dual-source allocation behavior and migration rollback. Tests refactored with helper consolidation and new ChangesCommitted Resource Reservation Blocking Logic
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Test Coverage ReportTest Coverage 📊: 69.1% |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/scheduling/nova/plugins/filters/filter_has_enough_capacity_test.go (1)
1277-1291: 💤 Low valueConsider using DeepCopy for consistency with other tests.
Other test functions in this file deep-copy hypervisors and reservations before passing them to the fake client (e.g., lines 574-580, 786-792). While the fake client likely handles this internally, using DeepCopy here would maintain consistency and prevent potential mutation issues if test objects are ever reused.
♻️ Suggested change
for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - objects := []client.Object{tt.hvA, tt.hvB, tt.resA, tt.resB} + objects := []client.Object{ + tt.hvA.DeepCopy(), + tt.hvB.DeepCopy(), + tt.resA.DeepCopy(), + tt.resB.DeepCopy(), + } step := &FilterHasEnoughCapacity{}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/scheduling/nova/plugins/filters/filter_has_enough_capacity_test.go` around lines 1277 - 1291, The test currently passes tt.hvA, tt.hvB, tt.resA, tt.resB directly into the fake client; to match other tests and avoid mutation issues, create DeepCopy() clones of these objects (e.g., call tt.hvA.DeepCopy(), tt.hvB.DeepCopy(), tt.resA.DeepCopy(), tt.resB.DeepCopy()) and use the clones in the objects slice passed to fake.NewClientBuilder().WithObjects(...).Build(); this keeps behavior consistent with other tests that deep-copy hypervisors and reservations before invoking FilterHasEnoughCapacity.Run.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/scheduling/nova/plugins/filters/filter_has_enough_capacity_test.go`:
- Around line 1277-1291: The test currently passes tt.hvA, tt.hvB, tt.resA,
tt.resB directly into the fake client; to match other tests and avoid mutation
issues, create DeepCopy() clones of these objects (e.g., call tt.hvA.DeepCopy(),
tt.hvB.DeepCopy(), tt.resA.DeepCopy(), tt.resB.DeepCopy()) and use the clones in
the objects slice passed to fake.NewClientBuilder().WithObjects(...).Build();
this keeps behavior consistent with other tests that deep-copy hypervisors and
reservations before invoking FilterHasEnoughCapacity.Run.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ce4563ed-798c-47dc-a24b-66c9fe05cdd5
📒 Files selected for processing (2)
internal/scheduling/nova/plugins/filters/filter_has_enough_capacity.gointernal/scheduling/nova/plugins/filters/filter_has_enough_capacity_test.go
Fixes capacity blocking for CommittedResource reservation slots that contain multiple VMs at different confirmation stages.