Conversation
📝 WalkthroughWalkthroughThe pull request adds monitoring capabilities to the failover reservation controller by introducing a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✏️ 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. Comment |
Test Coverage ReportTest Coverage 📊: 68.4% |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/scheduling/reservations/failover/controller.go`:
- Around line 332-334: summary.totalReservations is being set from the
pre-creation slice (failoverReservations) so it underreports when step 6 creates
additional reservations; update the controller so summary.totalReservations
reflects the actual number after creation by recalculating it once reservation
creation completes (e.g., set summary.totalReservations =
len(failoverReservations) after any newly created reservations have been
appended, or increment summary.totalReservations during the creation loop),
referencing the summary.totalReservations and failoverReservations variables in
the reservation creation flow in controller.go.
In `@internal/scheduling/reservations/scheduler_client.go`:
- Around line 144-147: The current log call logger.V(1).Info("sending external
scheduler request", "url", c.URL, "request", externalSchedulerRequest) leaks
potentially sensitive/high-cardinality data; update the log to remove
externalSchedulerRequest and instead log only explicit, sanitized fields (e.g.,
pipeline ID or name if safe, counts, and boolean flags). Locate the call using
logger.V(1).Info and replace the "request" field with a small structured payload
such as ("pipeline", safePipelineID), ("task_count", len(...)), ("has_priority",
externalSchedulerRequest.Priority != nil) or similar sanitized values derived
from externalSchedulerRequest; ensure no raw identifiers or entire payloads are
logged. Ensure c.URL remains if allowed but avoid including any fields that
could leak identifiers.
🪄 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: 60802461-e0fb-4f7e-8dc9-b620d836dfc9
📒 Files selected for processing (6)
cmd/main.gointernal/scheduling/reservations/failover/controller.gointernal/scheduling/reservations/failover/integration_test.gointernal/scheduling/reservations/failover/monitor.gointernal/scheduling/reservations/failover/monitor_test.gointernal/scheduling/reservations/scheduler_client.go
| summary.duration = time.Since(startTime) | ||
| summary.totalVMs = len(vms) | ||
| summary.totalReservations = len(failoverReservations) |
There was a problem hiding this comment.
totalReservations is underreported after reservation creation.
On Line 334, summary.totalReservations = len(failoverReservations) uses the pre-creation slice size. Since step 6 can create reservations, the logged/recorded total will be too low.
🔧 Proposed fix
- summary.totalReservations = len(failoverReservations)
+ summary.totalReservations = len(failoverReservations) + summary.totalCreated📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| summary.duration = time.Since(startTime) | |
| summary.totalVMs = len(vms) | |
| summary.totalReservations = len(failoverReservations) | |
| summary.duration = time.Since(startTime) | |
| summary.totalVMs = len(vms) | |
| summary.totalReservations = len(failoverReservations) + summary.totalCreated |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@internal/scheduling/reservations/failover/controller.go` around lines 332 -
334, summary.totalReservations is being set from the pre-creation slice
(failoverReservations) so it underreports when step 6 creates additional
reservations; update the controller so summary.totalReservations reflects the
actual number after creation by recalculating it once reservation creation
completes (e.g., set summary.totalReservations = len(failoverReservations) after
any newly created reservations have been appended, or increment
summary.totalReservations during the creation loop), referencing the
summary.totalReservations and failoverReservations variables in the reservation
creation flow in controller.go.
| logger.V(1).Info("sending external scheduler request", | ||
| "url", c.URL, | ||
| "instanceUUID", req.InstanceUUID, | ||
| "projectID", req.ProjectID, | ||
| "flavorName", req.FlavorName, | ||
| "flavorExtraSpecs", req.FlavorExtraSpecs, | ||
| "memoryMB", req.MemoryMB, | ||
| "vcpus", req.VCPUs, | ||
| "eligibleHostsCount", len(req.EligibleHosts), | ||
| "ignoreHosts", req.IgnoreHosts, | ||
| "isEvacuation", req.isEvacuation()) | ||
| "request", externalSchedulerRequest) | ||
|
|
There was a problem hiding this comment.
Avoid logging the full scheduler request payload
Logging externalSchedulerRequest can leak identifiers/hints and creates high-cardinality/noisy logs. Prefer explicit, sanitized fields only (counts/flags/pipeline).
Suggested change
logger.V(1).Info("sending external scheduler request",
"url", c.URL,
- "request", externalSchedulerRequest)
+ "pipeline", req.Pipeline,
+ "eligibleHostsCount", len(req.EligibleHosts),
+ "ignoreHostsCount", len(req.IgnoreHosts),
+ "hasSchedulerHints", len(req.SchedulerHints) > 0,
+ "availabilityZone", req.AvailabilityZone)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@internal/scheduling/reservations/scheduler_client.go` around lines 144 - 147,
The current log call logger.V(1).Info("sending external scheduler request",
"url", c.URL, "request", externalSchedulerRequest) leaks potentially
sensitive/high-cardinality data; update the log to remove
externalSchedulerRequest and instead log only explicit, sanitized fields (e.g.,
pipeline ID or name if safe, counts, and boolean flags). Locate the call using
logger.V(1).Info and replace the "request" field with a small structured payload
such as ("pipeline", safePipelineID), ("task_count", len(...)), ("has_priority",
externalSchedulerRequest.Priority != nil) or similar sanitized values derived
from externalSchedulerRequest; ensure no raw identifiers or entire payloads are
logged. Ensure c.URL remains if allowed but avoid including any fields that
could leak identifiers.
No description provided.