fix: stop committed resource controller reconcile storm#1089
fix: stop committed resource controller reconcile storm#1089juliusclausnitzer wants to merge 1 commit into
Conversation
setAccepted unconditionally wrote a new AcceptedAt timestamp and a time-varying StatusSummary on every call, causing a non-empty status patch even when the CR was already accepted for the current generation. The self-watch (EnqueueRequestForObject) fired on each patch, re-enqueuing every accepted cores commitment in a tight ~2s loop and keeping the workqueue depth permanently elevated around 80. Add an early-return guard in setAccepted that skips the patch when Ready=True/Accepted is already set for the current generation. Signed-off-by: Julius Clausnitzer <julius.clausnitzer@sap.com>
📝 WalkthroughWalkthroughThe committed resource controller now skips redundant Accepted status patches when the condition is current. A unit test verifies the initial status update and confirms a second reconcile leaves the resource version unchanged. ChangesCommitted resource acceptance
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
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/scheduling/reservations/commitments/committed_resource_controller_test.go`:
- Around line 1173-1176: Update the test setup around newTestCoresCR and the
first reconcile to set cr.Generation to 1 before creating the test client, then
assert that the accepted condition’s ObservedGeneration equals 1 after
reconciliation. Keep the existing condition assertions and test flow unchanged.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b57c19c7-e446-4ab0-8fb7-912f482a2414
📒 Files selected for processing (2)
internal/scheduling/reservations/commitments/committed_resource_controller.gointernal/scheduling/reservations/commitments/committed_resource_controller_test.go
| scheme := newCRTestScheme(t) | ||
| cr := newTestCoresCR("test-cr", v1alpha1.CommitmentStatusConfirmed, 4, false) | ||
| fgc := newTestFlavorGroupCapacity("test-group", "test-az", 16) | ||
| k8sClient := newCRTestClient(scheme, cr, fgc) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Exercise a non-zero generation in this test.
The fixture does not explicitly set metadata.generation, so a zero-generation test client could allow an implementation that incorrectly records ObservedGeneration=0 to pass. Seed cr.Generation = 1 and assert the accepted condition’s ObservedGeneration after the first reconcile.
Suggested test hardening
cr := newTestCoresCR("test-cr", v1alpha1.CommitmentStatusConfirmed, 4, false)
+cr.Generation = 1
fgc := newTestFlavorGroupCapacity("test-group", "test-az", 16)
...
rv1 := after1.ResourceVersion
+cond := meta.FindStatusCondition(after1.Status.Conditions, v1alpha1.CommittedResourceConditionReady)
+if cond == nil || cond.ObservedGeneration != after1.Generation {
+ t.Fatalf("expected ObservedGeneration=%d, got %#v", after1.Generation, cond)
+}Also applies to: 1184-1194
🤖 Prompt for 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.
In
`@internal/scheduling/reservations/commitments/committed_resource_controller_test.go`
around lines 1173 - 1176, Update the test setup around newTestCoresCR and the
first reconcile to set cr.Generation to 1 before creating the test client, then
assert that the accepted condition’s ObservedGeneration equals 1 after
reconciliation. Keep the existing condition assertions and test flow unchanged.
Test Coverage ReportTest Coverage 📊: 70.3% |
setAccepted unconditionally wrote a new AcceptedAt timestamp and a time-varying StatusSummary on every call, causing a non-empty status patch even when the CR was already accepted for the current generation. The self-watch (EnqueueRequestForObject) fired on each patch, re-enqueuing every accepted cores commitment in a tight ~2s loop and keeping the workqueue depth permanently elevated around 80.
Add an early-return guard in setAccepted that skips the patch when Ready=True/Accepted is already set for the current generation.