Skip to content

fix(controller): Do not extend sandbox ShutdownTime on malformed pause-retention annotation - #890

Open
vishalmore90 wants to merge 2 commits into
openkruise:masterfrom
vishalmore90:fix-issue-889
Open

fix(controller): Do not extend sandbox ShutdownTime on malformed pause-retention annotation#890
vishalmore90 wants to merge 2 commits into
openkruise:masterfrom
vishalmore90:fix-issue-889

Conversation

@vishalmore90

Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR does

Fixes a logic bug where a malformed agents.kruise.io/reserve-paused-sandbox-duration annotation causes resolveRetentionAnnotationOrDefault to silently return managed=true.

This previously caused handlePauseTimeout to extend Spec.ShutdownTime by ~100 years the next time the sandbox auto-pauses, instead of cleanly treating the invalid annotation as absent.

The fix correctly returns managed=false for unparsable annotations and emits a Kubernetes Warning event to help operators identify the misconfiguration.

Ⅱ. Does this pull request fix one issue?

fixes #889

Ⅲ. Describe how to verify it

  1. Create a Sandbox with a PauseTime in the near future and a ShutdownTime.
  2. Annotate the sandbox: kubectl annotate sandbox <name> agents.kruise.io/reserve-paused-sandbox-duration=invalid-duration.
  3. Wait for PauseTime to be reached.
  4. Observe that a Warning event is generated (InvalidRetentionAnnotation).
  5. Observe that the Sandbox reaches its PauseTime and gets paused, but its ShutdownTime remains unchanged and is not extended by 100 years.
  6. Verify the Sandbox gets correctly garbage collected when its original ShutdownTime is reached.
  7. Run make test and ensure the updated test case invalid annotation patches paused without extending shutdown time passes.

Ⅳ. Special notes for reviews

The test case "invalid annotation patches paused without backfilling default" in sandbox_controller_test.go inadvertently encoded the bug's behavior (expectShutdownChange: true). This PR updates that test case to correctly expect expectShutdownChange: false and renames it.

…e-retention annotation

Signed-off-by: vishal <httpsvishal07@gmail.com>
@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 assign airanthem for approval by writing /assign @airanthem 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 Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.39%. Comparing base (825de1d) to head (01da012).
⚠️ Report is 21 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #890      +/-   ##
==========================================
+ Coverage   82.31%   82.39%   +0.07%     
==========================================
  Files         244      254      +10     
  Lines       19782    21461    +1679     
==========================================
+ Hits        16284    17683    +1399     
- Misses       2888     3079     +191     
- Partials      610      699      +89     
Flag Coverage Δ
unittests 82.39% <100.00%> (+0.07%) ⬆️

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.

@vishalmore90

Copy link
Copy Markdown
Contributor Author

/Review

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.

[BUG] Malformed AnnotationReservePausedSandboxDuration silently extends sandbox ShutdownTime by 100 years

2 participants