Skip to content

fix: handle edge cases in sandbox reuse lifecycle#569

Open
zmberg wants to merge 1 commit into
openkruise:masterfrom
zmberg:fix-reuse
Open

fix: handle edge cases in sandbox reuse lifecycle#569
zmberg wants to merge 1 commit into
openkruise:masterfrom
zmberg:fix-reuse

Conversation

@zmberg

@zmberg zmberg commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Fail reuse immediately when Pod enters terminal phase (Succeeded/Failed) instead of waiting for timeout
  • Add polling-based requeue during reuse in-progress to guarantee timeout fires even without external events
  • Prioritize reuse trigger over Pod terminal detection in Running phase to prevent sandbox stuck in Failed with dirty claim metadata
  • Preserve AnnotationReuseEnabled when clearing internal annotations in SandboxSet
  • Add ReuseCount printer column to Sandbox CRD

Test plan

  • Unit tests added for terminal phase detection (PodSucceeded/PodFailed)
  • Existing reuse tests updated for polling requeue behavior

🤖 Generated with Claude Code

@kruise-bot

Copy link
Copy Markdown

[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 ask for approval from zmberg by writing /assign @zmberg in a comment. 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

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.11111% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.66%. Comparing base (901921b) to head (4d09ac8).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controller/sandbox/sandbox_controller.go 30.55% 20 Missing and 5 partials ⚠️
pkg/controller/sandbox/core/reuse.go 91.17% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #569      +/-   ##
==========================================
- Coverage   79.78%   79.66%   -0.13%     
==========================================
  Files         202      202              
  Lines       14688    14796     +108     
==========================================
+ Hits        11719    11787      +68     
- Misses       2544     2573      +29     
- Partials      425      436      +11     
Flag Coverage Δ
unittests 79.66% <61.11%> (-0.13%) ⬇️

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.

@zmberg zmberg force-pushed the fix-reuse branch 3 times, most recently from 30a6eb3 to ed4bb93 Compare June 24, 2026 09:28
@kruise-bot kruise-bot added size/XL and removed size/L labels Jun 24, 2026
return 0, fmt.Errorf("pod not found during reuse")
sbs, err := r.validateReusePreconditions(ctx, args)
if err != nil {
return 0, err

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if validation fail, shall we delete the sandbox directly ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, handleReuseFailed will handle that uniformly.

return nil, fmt.Errorf("pod not found during reuse")
}

// If the Pod has already entered a terminal phase (Succeeded/Failed), the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shall we check the following condition

  1. whether sandbox is paused ?
  2. whether sandbox has pvc ?

Signed-off-by: liheng <liheng.zms@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants