fix(CR): subtract reservation CPU blocks when counting placeable slots - #1118
Conversation
Signed-off-by: Marcel <156897072+mblos@users.noreply.github.com>
📝 WalkthroughWalkthroughReservation capacity reconciliation now tracks blocked memory and CPU per host. The nested reservation map flows through capacity calculations, scheduler probes, split inputs, and availability-zone reconciliation. Tests now use the expanded map shape. ChangesReservation capacity reconciliation
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 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
🧹 Nitpick comments (1)
internal/scheduling/reservations/capacity/controller_test.go (1)
1035-1036: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover CPU reservation blocks in the regression test.
This test injects only
ResourceMemory, so it does not exercise theResourceCoressubtraction atinternal/scheduling/reservations/capacity/controller.go, Line [354]. The flavor also has noVCPUsvalue. Configure CPU capacity and demand, add aResourceCoresreservation block, and assert the reduced placeable slot count. Add a focused aggregation case ifblockedResourcesByHostis not covered elsewhere.🤖 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/capacity/controller_test.go` around lines 1035 - 1036, Extend the regression test around blockedByReservations to configure flavor CPU capacity and demand, include a ResourceCores reservation block, and assert the reduced placeable slot count. Ensure the test exercises the ResourceCores subtraction in the capacity controller; add a focused blockedResourcesByHost aggregation case only if that behavior lacks coverage elsewhere.
🤖 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/capacity/controller.go`:
- Around line 241-244: Do not fail open when reservation inventory is
incomplete: in internal/scheduling/reservations/capacity/controller.go lines
241-244, update the reconciliation flow around blockedResourcesByHost to return
or skip reconciliation on error instead of substituting an empty map; at lines
798-807, enforce the reservation-list contract’s per-cluster failure reporting
before constructing the blocked-resource map, preserving the existing successful
path.
---
Nitpick comments:
In `@internal/scheduling/reservations/capacity/controller_test.go`:
- Around line 1035-1036: Extend the regression test around blockedByReservations
to configure flavor CPU capacity and demand, include a ResourceCores reservation
block, and assert the reduced placeable slot count. Ensure the test exercises
the ResourceCores subtraction in the capacity controller; add a focused
blockedResourcesByHost aggregation case only if that behavior lacks coverage
elsewhere.
🪄 Autofix
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: ac67df25-709e-425d-9cf9-6d698b851334
📒 Files selected for processing (2)
internal/scheduling/reservations/capacity/controller.gointernal/scheduling/reservations/capacity/controller_test.go
Test Coverage ReportTest Coverage 📊: 70.6% |
## Release cortex v0.3.6 ### New features - **Implement in-flight reservations controller** — adds a new controller that tracks reservations currently being fulfilled by monitoring VM creation state via Nova API, transitioning reservations through their lifecycle stages and cleaning up stale in-flight reservations ([#957](#957)) - **Add KPI that tracks CR count per configured cluster** — introduces the `MulticlusterObjectCountKPI` plugin which counts custom resource objects per cluster and exposes them as Prometheus metrics ([#1054](#1054)) - **Follow VM live migration in CR reservation reconciler** — the committed resource reservation controller now detects when a VM has been live-migrated to a different host and updates the reservation's target host accordingly ([#1048](#1048)) ### Bug fixes - **Subtract reservation CPU blocks when counting placeable slots** — the capacity accounting now correctly deducts reserved CPU blocks from available capacity before calculating how many new instances can be placed ([#1118](#1118)) ### Non-breaking changes - Skip non-candidate hypervisors in nova filters and weighers ([#1117](#1117)) - Add dynamic labels to pipeline step event metrics ([#1108](#1108)) - Update `go.xyrillian.de/gg` to v1.13.2 ([#1111](#1111), [#1122](#1122)) - Update `github.com/sapcc/go-bits` ([#1124](#1124)) - Update `kube-prometheus-stack` to v88.1.5 ([#1112](#1112), [#1119](#1119), [#1121](#1121)) - Update `debian:trixie-slim` Docker digest ([#1120](#1120)) ### Chart versions | Chart | Old | New | |-------|-----|-----| | cortex | 0.3.5 | 0.3.6 | | cortex-shim | 0.1.11 | 0.1.12 | | cortex-postgres | 0.6.11 | 0.6.12 | | cortex-nova | 0.0.85 | 0.0.86 | | cortex-cinder | 0.0.85 | 0.0.86 | | cortex-manila | 0.0.85 | 0.0.86 | | cortex-crds | 0.0.85 | 0.0.86 | | cortex-ironcore | 0.0.85 | 0.0.86 | | cortex-pods | 0.0.85 | 0.0.86 | | cortex-placement-shim | 0.1.11 | 0.1.12 |
Fixes capacity slot counting to use both memory and CPU as binding constraints, not memory alone.