feat: add kvm_committed_resource_reservation weigher#854
feat: add kvm_committed_resource_reservation weigher#854juliusclausnitzer wants to merge 3 commits into
Conversation
Weigher boosts hosts that have a ready CommittedResourceReservation matching the request's project, resource group, and AZ with enough free memory for the requested flavor. Activated in the two real-placement KVM pipelines (general-purpose and hana) that have createHistory=true.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds a new Nova KVM scheduler weigher that filters ready CommittedResourceReservation objects by project, resource group, and availability zone, computes free memory per reservation, and weights hosts accordingly; the weigher is added to two KVM scheduling pipelines via Helm. ChangesKVM Committed Resource Reservation Weigher
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 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 unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 (2)
internal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation_test.go (1)
22-22: 💤 Low valueConsider using numeric formatting for VM UUID generation.
The current approach
string(rune('a'+i))works but only supports 26 allocations (a-z) before producing non-ASCII characters. While adequate for these tests, usingfmt.Sprintf("vm-%d", i)would be more robust and clearer.♻️ Alternative approach
- vmUUID := "vm-" + string(rune('a'+i)) + vmUUID := fmt.Sprintf("vm-%d", i)🤖 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/nova/plugins/weighers/kvm_committed_resource_reservation_test.go` at line 22, The vm UUID generation using vmUUID := "vm-" + string(rune('a'+i)) is fragile (only 26 letters) — change it to numeric formatting (e.g., vmUUID := fmt.Sprintf("vm-%d", i)) in the test so it scales beyond 26 VMs; update imports to include fmt if missing and adjust any related expectations that assume letter-based names (reference symbol: vmUUID in kvm_committed_resource_reservation_test.go).internal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation.go (1)
70-70: ⚡ Quick winNote: This pattern of using
context.Background()is consistent across all weighers in the codebase.All weigher implementations (
kvm_prefer_smaller_hosts,kvm_instance_group_soft_affinity,kvm_failover_reservation_consolidation,kvm_failover_evacuation,kvm_binpack) usecontext.Background()forClient.List()calls. If there's a concern about cancellation support for list operations, it should be addressed as a codebase-wide refactoring rather than in individual weighers. Changing only this file would create inconsistency with the established pattern.🤖 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/nova/plugins/weighers/kvm_committed_resource_reservation.go` at line 70, The File uses context.Background() when calling s.Client.List (in kvm_committed_resource_reservation.go) which is consistent with other weighers (kvm_prefer_smaller_hosts, kvm_instance_group_soft_affinity, kvm_failover_reservation_consolidation, kvm_failover_evacuation, kvm_binpack); do not change this single call to a cancellable context here—either leave the s.Client.List(context.Background(), &reservations) call as-is or implement a coordinated, repository-wide refactor that replaces context.Background() usage in all weigher implementations and the Client.List call sites at once to add cancellation support.
🤖 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/nova/plugins/weighers/kvm_committed_resource_reservation_test.go`:
- Line 19: The function signature for newCRReservation currently declares
consecutive string parameters separately (az string, totalMemory string); change
it to combine their types as (az, totalMemory string) in the newCRReservation
declaration and update any call sites that mirror the old ordering if needed so
the parameter list and calls remain consistent.
---
Nitpick comments:
In
`@internal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation_test.go`:
- Line 22: The vm UUID generation using vmUUID := "vm-" + string(rune('a'+i)) is
fragile (only 26 letters) — change it to numeric formatting (e.g., vmUUID :=
fmt.Sprintf("vm-%d", i)) in the test so it scales beyond 26 VMs; update imports
to include fmt if missing and adjust any related expectations that assume
letter-based names (reference symbol: vmUUID in
kvm_committed_resource_reservation_test.go).
In
`@internal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation.go`:
- Line 70: The File uses context.Background() when calling s.Client.List (in
kvm_committed_resource_reservation.go) which is consistent with other weighers
(kvm_prefer_smaller_hosts, kvm_instance_group_soft_affinity,
kvm_failover_reservation_consolidation, kvm_failover_evacuation, kvm_binpack);
do not change this single call to a cancellable context here—either leave the
s.Client.List(context.Background(), &reservations) call as-is or implement a
coordinated, repository-wide refactor that replaces context.Background() usage
in all weigher implementations and the Client.List call sites at once to add
cancellation support.
🪄 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: 08a689a5-fe8b-4d4f-90de-0ed85e44b6f4
📒 Files selected for processing (3)
helm/bundles/cortex-nova/templates/pipelines_kvm.yamlinternal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation.gointernal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation_test.go
30881fc to
3e0fd91
Compare
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/nova/plugins/weighers/kvm_committed_resource_reservation_test.go`:
- Around line 56-81: The newCRRequest function has an unused parameter
(flavorMemoryMB) flagged by unparam; remove the parameter from newCRRequest's
signature and hardcode the MemoryMB value to 8*1024 when constructing
api.NovaFlavor in newCRRequest, and update all call sites that pass the first
argument (currently all pass 8*1024) to call newCRRequest with only the hosts
argument; ensure references to flavorMemoryMB and any related variable
initializations are removed so newCRRequest and its usage compile cleanly.
🪄 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: 2604758b-f54a-4c8c-ba6a-c8fba3f2219d
📒 Files selected for processing (3)
helm/bundles/cortex-nova/templates/pipelines_kvm.yamlinternal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation.gointernal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
- helm/bundles/cortex-nova/templates/pipelines_kvm.yaml
- internal/scheduling/nova/plugins/weighers/kvm_committed_resource_reservation.go
Test Coverage ReportTest Coverage 📊: 69.3% |
Weigher boosts hosts that have a ready CommittedResourceReservation matching the request's project, resource group, and AZ with enough free memory for the requested flavor. Activated in the two real-placement KVM pipelines (general-purpose and hana) that have createHistory=true.