fix: correct warm pool sandbox deletion when policy is retain#645
Conversation
✅ Deploy Preview for agent-sandbox canceled.
|
|
Welcome @alimx07! |
|
Hi @alimx07. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
Fixes Sandbox deletion for expired SandboxClaims with ShutdownPolicy=Retain when the Sandbox was adopted from a SandboxWarmPool (and therefore doesn’t share the claim’s name). This aligns cleanup behavior across direct-created and warm-pool-adopted Sandboxes.
Changes:
- Update
reconcileExpiredto look up the Sandbox byclaim.Status.SandboxStatus.Name(fallback toclaim.Name). - Add an ownership guard (
metav1.IsControlledBy) before deleting a Sandbox on claim expiration. - Extend
TestSandboxClaimCleanupPolicywith a warm-pool-adoption scenario and adjust sandbox lookup assertions accordingly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
extensions/controllers/sandboxclaim_controller.go |
Fixes expired-claim sandbox lookup for warm-pool-adopted sandboxes and adds an ownership guard before deletion. |
extensions/controllers/sandboxclaim_controller_test.go |
Adds/adjusts test coverage to validate deletion behavior when the adopted sandbox name differs from the claim name. |
|
/ok-to-test |
a47b042 to
c5578e4
Compare
72ab74c to
9f71448
Compare
|
/ok-to-test |
9f71448 to
79cc61f
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alimx07, barney-s 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 |
Fix: delete warm-pool-adopted Sandboxes when SandboxClaim expires with Policy=Retain
Problem
SandboxClaimReconciler.reconcileExpiredlooks up the Sandbox to delete usingclient.ObjectKeyFromObject(claim), i.e.{claim.Namespace, claim.Name}. This works for Sandboxes created directly from a claim (they are named after the claim), but fails for Sandboxes adopted from aSandboxWarmPool.Adopted Sandboxes keep the name the warm pool gave (e.g.
basic-warmpool-a1b2c3). When the claim expires underShutdownPolicy=Retain, the controller's lookup byclaim.NamereturnsNotFound, the function returnsnil, nilOfc, GC does not save us here: as the sandbox is still referenced with the claim. Once we delete the claim, everything is good.
Fix
Look up the Sandbox by
claim.Status.SandboxStatus.Namewhen populated. This field is maintained bycomputeAndSetStatusto track the actual Sandbox name (direct or adopted). Fall back toclaim.Namewhen status is unset, which preserves existing behavior for direct-created Sandboxes whose names are equal to the claim name anyway.I also add a verfication to ensure the ownership between claim & sandbox before deletion using
!metav1.IsControlledBy(sandbox, claim)Tests
TestSandboxClaimCleanupPolicyby adding a new test case (isWarmPool: true) to specifically simulate an adopted warm-pool sandbox.Sandboxusing its actual initialized name (which can differ from the claim).