feat: bypass grace period for confirmed VM departure - #925
Conversation
Confirmed VMs (present in Status.Allocations) now bypass the grace period check when they disappear from the HV CRD. Their departure is authoritative — Spec.Allocations and Status.Allocations are cleared in the same reconcile pass triggered by the existing HV watch. Previously the grace period gate applied to all VMs regardless of confirmation state, meaning a confirmed VM's departure could be delayed up to 15 minutes.
|
Warning Review limit reached
More reviews will be available in 55 minutes and 58 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesConfirmed VM Grace-Period Logic
Possibly Related PRs
Suggested Reviewers
Poem
🎯 2 (Simple) | ⏱️ ~18 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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: 2
🤖 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/reservation_controller_test.go`:
- Around line 377-380: The failure assertion dereferences
updated.Status.CommittedResourceReservation.Allocations which can panic when
CommittedResourceReservation is nil; change the test to avoid dereferencing in
the error message by printing the whole CommittedResourceReservation safely
(e.g., pass updated.Status.CommittedResourceReservation or use
fmt.Sprintf("%#v", updated.Status.CommittedResourceReservation)) or
conditionally format the allocations only when CommittedResourceReservation !=
nil, and update the t.Errorf call that references
CommittedResourceReservation.Allocations so it never directly dereferences a nil
pointer.
In `@internal/scheduling/reservations/commitments/reservation_controller.go`:
- Around line 418-419: The code currently treats an allocation as confirmed by
checking existingStatusAllocations[vmUUID] != "" which misclassifies keys
present with empty values; change the confirmation check to use map membership
instead (e.g., _, isConfirmed := existingStatusAllocations[vmUUID]) so
isConfirmed is true if the key exists regardless of its value, then keep the
subsequent condition using isInGracePeriod unchanged to correctly apply
grace-period deferral.
🪄 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
Run ID: 98ce2dfe-868b-495e-b7ff-b5f047613cf1
📒 Files selected for processing (2)
internal/scheduling/reservations/commitments/reservation_controller.gointernal/scheduling/reservations/commitments/reservation_controller_test.go
Test Coverage ReportTest Coverage 📊: 69.6% |
## Release cortex core v0.1.2 & bundles v0.0.76 ### Prerequisites - [x] Merge chart-bump PR: #969 - [x] Merge changelog PR: #970 - [x] Merge changelog update PR: #974 ### cortex v0.1.2 (sha-6daa5050) Non-breaking changes: - Pre-allocate PAYG VMs into CR reservation slots on CR creation/modification (#951) - Keep failover allocation if VM missing from postgres but present on hypervisor (#909) - All datasources are synced on restart (#956) - Honor domain restrictions for CR reservation scheduling (#955) - Create InFlightReservation as part of Reservation CRD (#954) - Move committed resource status summary business logic to internal (#953) - Bypass grace period for confirmed VM departure (#925) - Track VM placements in reservations and classify no-host-found (#847) - Refactor reservations: move VMSource to shared package, unify VM data layer (#930) - Add suffix gX to postgresql (#939) - Update External dependencies to v1.9.1 (#952), v1.14.46 (#959) - Update `github.com/sapcc` (#938) ### cortex-nova v0.0.76 Includes updated chart cortex v0.1.2. - Add `keystoneSecretRef` and `ssoSecretRef` config keys for domain resolution in committed resource reservation scheduling (#955) - Add `enablePaygPreAllocation` config key for pre-allocating PAYG VMs into reservation slots (#951) ### cortex-crds v0.0.76 Includes updated chart cortex v0.1.2. ### cortex-cinder v0.0.76 Includes updated chart cortex v0.1.2. ### cortex-pods v0.0.76 Includes updated chart cortex v0.1.2. ### cortex-ironcore v0.0.76 Includes updated chart cortex v0.1.2. ### cortex-manila v0.0.76 Includes updated chart cortex v0.1.2. ### General - Switch chart appVersion bump to PR-based flow via ghcr (#943) - Track Helm chart appVersions via custom regex managers (#940) - Document candidate reservation cleanup on VM confirm (#916) - Document scheduling.Options struct fields (#941)
…dead cross-reference (#962) The VMSource refactor (#930) moved vm_source.go to the shared reservations package (internal/scheduling/reservations/) but the failover-reservations doc still listed it under the failover subdirectory. The grace period bypass for confirmed VMs (#925) changed allocation verification behavior — confirmed VMs are now removed immediately when they disappear from the Hypervisor CRD, without waiting for the grace period — but the committed-resource-reservations doc still described a single grace-period path for all missing VMs. Additionally, a dangling cross-reference pointed to non-existent "pessimistic blocking reservations documentation" and has been replaced with an inline explanation of InFlightReservation CRDs. Assisted-by: Claude Code:claude-sonnet-4-20250514 [Bash] [Read] Co-authored-by: cortex-ai-agents[bot] <279748396+cortex-ai-agents[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Confirmed VMs (present in Status.Allocations) now bypass the grace period check when they disappear from the HV CRD. Their departure is authoritative — Spec.Allocations and Status.Allocations are cleared in the same reconcile pass triggered by the existing HV watch.
Previously the grace period gate applied to all VMs regardless of confirmation state, meaning a confirmed VM's departure could be delayed up to 15 minutes.