Skip to content

fix(workloadmanager): check CodeInterpreter child ownership - #450

Open
avinxshKD wants to merge 4 commits into
volcano-sh:mainfrom
avinxshKD:fix/codeinterpreter-child-ownership
Open

fix(workloadmanager): check CodeInterpreter child ownership#450
avinxshKD wants to merge 4 commits into
volcano-sh:mainfrom
avinxshKD:fix/codeinterpreter-child-ownership

Conversation

@avinxshKD

Copy link
Copy Markdown

*What type of PR is this?

/kind bug

What this PR does / why we need it:

Prevents the CodeInterpreter controller from updating or deleting same-named SandboxTemplate and SandboxWarmPool resources that it does not own

Ownership conflicts now fail reconciliation and set the CodeInterpreter Ready condition to False with reason OwnershipConflict.

Which issue(s) this PR fixes:

Fixes #449

Special notes for your reviewer:

AlreadyExists from child creation is now returned so a concurrent name collision is retried and checked instead of being treated as success.

Does this PR introduce a user-facing change?:

CodeInterpreter no longer modifies or deletes unowned SandboxTemplate and SandboxWarmPool resources.

Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
Copilot AI review requested due to automatic review settings August 2, 2026 16:52
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@volcano-sh-bot volcano-sh-bot added the kind/bug Something isn't working label Aug 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign yaozengzeng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@avinxshKD

Copy link
Copy Markdown
Author

@ranxi2001 @acsoto ptal when u get chance, this prevents the CodeInterpreter controller from modifying or deleting same-named resources it doesn’t own.

@codecov-commenter

codecov-commenter commented Aug 2, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 81.57895% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.25%. Comparing base (3b19390) to head (0b646d8).
⚠️ Report is 36 commits behind head on main.

Files with missing lines Patch % Lines
pkg/workloadmanager/codeinterpreter_controller.go 81.57% 5 Missing and 2 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #450      +/-   ##
==========================================
+ Coverage   58.41%   61.25%   +2.83%     
==========================================
  Files          36       36              
  Lines        3463     3613     +150     
==========================================
+ Hits         2023     2213     +190     
+ Misses       1231     1171      -60     
- Partials      209      229      +20     
Flag Coverage Δ
unittests 61.25% <81.57%> (+2.83%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

return err
}

if err := r.Delete(ctx, sandboxTemplate); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] Bind the ownership check to the object being deleted

Both delete helpers first GET the child and confirm metav1.IsControlledBy, but r.Delete(ctx, child) sends no UID or resourceVersion preconditions. Passing the fetched object to Delete does not automatically add those fields to DeleteOptions, so with another authorized writer the checked object and the deleted object can differ:

sequenceDiagram
    participant WM as CodeInterpreter controller
    participant API as Kubernetes API
    participant Other as Concurrent authorized writer

    WM->>API: GET child "test"
    API-->>WM: A (UID 111, RV 10, owned by this CodeInterpreter)
    Note over WM: IsControlledBy(A) is true
    Other->>API: Delete A
    Other->>API: Create B with the same name (UID 222, not owned)
    alt Current: DELETE has no preconditions
        WM->>API: DELETE "test" by namespace/name
        API-->>WM: Delete the current object B
    else Requested: bind DELETE to observed identity/version
        WM->>API: DELETE "test" with UID 111 and RV 10
        API-->>WM: Reject the stale request, then reconcile re-reads
    end
Loading

This is a source-proven latent race, not an observed failure: it requires a concurrent authorized writer to replace or mutate the child after the GET. Even so, the final DELETE can violate this PR's ownership invariant.

Could both delete helpers pass the observed UID and resourceVersion through client.Preconditions and return a precondition conflict so reconciliation re-reads the child? Please also add focused tests for both SandboxTemplate and SandboxWarmPool that replace or mutate the object between GET and DELETE.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, both delete paths now use UID and resourceVersion preconditions, with replacement-race tests for SandboxTemplate and SandboxWarmPool. PTAL. @ranxi2001

Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
Copilot AI review requested due to automatic review settings August 3, 2026 04:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
Copilot AI review requested due to automatic review settings August 3, 2026 04:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodeInterpreter controller can delete unowned SandboxTemplate resources

5 participants