Propagate warmpool label from sandbox to pod#927
Conversation
✅ Deploy Preview for agent-sandbox canceled.
|
|
/priority critical-urgent |
There was a problem hiding this comment.
Pull request overview
This PR enables propagation of a specific system-reserved label (agents.x-k8s.io/warm-pool-sandbox) from Sandbox.Spec.PodTemplate onto the created/adopted Pod, so warm pool capacity-buffer components can reliably select warm pool Pods by label.
Changes:
- Introduces an allowlist (“exception”) so
agents.x-k8s.io/warm-pool-sandboxis not treated as a blocked system label during Pod label propagation. - Adds a unit test verifying the exception label is propagated from the Sandbox PodTemplate to the resulting Pod (and recorded in the propagated-labels annotation).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| controllers/sandbox_controller.go | Adds a system-label exception so the warm pool label can propagate from Sandbox PodTemplate to Pod. |
| controllers/sandbox_controller_test.go | Adds a table-driven test case asserting the warm pool label exception is propagated to the Pod. |
2cff8e7 to
9c16e96
Compare
|
/lgtm |
|
@coderabbitai full review @shrutiyam-glitch let's try out Coderabbit reviews |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds an exported ChangesWarm-pool label constant and propagation
Sequence Diagram(s)sequenceDiagram
participant SandboxController
participant Sandbox
participant SandboxWarmPool
participant Pod
SandboxController->>Sandbox: fetch Sandbox
Sandbox->>SandboxController: return metadata (labels, ownerRef)
SandboxController->>SandboxWarmPool: inspect owner kind (Is SandboxWarmPool?)
alt owner is SandboxWarmPool and warm-pool label present
SandboxController->>Pod: create/update Pod with warm-pool label value
Pod->>SandboxController: acknowledge creation/update
else owner not SandboxWarmPool or label missing
SandboxController->>Pod: ensure warm-pool label removed
Pod->>SandboxController: acknowledge removal
end
🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels: Suggested reviewers:
🚥 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)
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 `@controllers/sandbox_controller.go`:
- Around line 942-958: The OwnerReference check uses only ref.Kind to detect a
SandboxWarmPool; update the logic around metav1.GetControllerOf(sandbox) to
validate both ref.Kind == "SandboxWarmPool" and ref.APIVersion == the expected
API version (the constant used for sandboxv1beta1 group/version) before treating
the sandbox as owned by a warm pool; change the condition that sets
expectedWarmPoolHash (and the similar check in reconcilePod) to require both
fields so the label add/remove logic for
pod.Labels[sandboxv1beta1.SandboxWarmPoolLabel] only runs when both Kind and
APIVersion match the SandboxWarmPool type.
- Around line 846-853: The OwnerReference check in the sandbox-to-pod label
propagation only compares ref.Kind and should also verify ref.APIVersion to
avoid false positives; update the condition around
metav1.GetControllerOf(sandbox) to require both ref.Kind == "SandboxWarmPool"
and ref.APIVersion == sandboxv1beta1.SchemeGroupVersion.String() (or the
appropriate group/version constant) before copying
sandboxv1beta1.SandboxWarmPoolLabel into podLabels, preserving the existing
label lookup logic.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 869c320c-e942-4341-b6ab-66849efc0d0f
📒 Files selected for processing (4)
api/v1beta1/sandbox_types.gocontrollers/sandbox_controller.gocontrollers/sandbox_controller_test.goextensions/controllers/sandboxwarmpool_controller.go
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: janetkuo, shrutiyam-glitch The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* Add exception for label propagation to pod * fmt * Add unit test for existing pod label propagation * Propagate warmpool label from sandbox to pod * Add swp label after scrubbing user-supplied labels * Verify API group
* Add exception for label propagation to pod * fmt * Add unit test for existing pod label propagation * Propagate warmpool label from sandbox to pod * Add swp label after scrubbing user-supplied labels * Verify API group
What this PR does / why we need it:
The system labels are not propagated from the sandbox to pod currently - https://github.com/kubernetes-sigs/agent-sandbox/blob/main/controllers/sandbox_controller.go#L836.
However, the label
agents.x-k8s.io/warm-pool-sandboxis required by the capacity buffer to identify the pods belonging to a warmpool using this label selector.Explicitly added the warmpool labels to the pod based on the Sandbox ownership and its labels.
Added unit tests for different cases.
Test:
Which issue(s) this PR is related to:
Summary by CodeRabbit