Skip to content

fix(workloadmanager): deduplicate GC candidates before deletion#335

Merged
volcano-sh-bot merged 3 commits into
volcano-sh:mainfrom
Abhinav-kodes:fix-gc-duplicate-sandbox-deletion
May 19, 2026
Merged

fix(workloadmanager): deduplicate GC candidates before deletion#335
volcano-sh-bot merged 3 commits into
volcano-sh:mainfrom
Abhinav-kodes:fix-gc-duplicate-sandbox-deletion

Conversation

@Abhinav-kodes
Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

The garbage collector's once() method merges two candidate lists - inactive sandboxes (idle timeout elapsed) and expired sandboxes (past TTL) - before iterating over them for deletion. A sandbox that qualifies for both conditions appears in both lists, causing the GC to attempt deleting it twice in the same cycle. The second attempt fails on DeleteSandboxBySessionID (store entry already removed) and logs a spurious error.

This PR deduplicates the merged candidate slice by SessionID before the deletion loop, ensuring each sandbox is processed exactly once.

Special notes for your reviewer:

The deduplication uses a map[string]struct{} keyed by SessionID. Inactive sandboxes are inserted first, then expired ones, preserving the original iteration order while skipping duplicates.

Does this PR introduce a user-facing change?:

NONE

Signed-off-by: Abhinav Singh <abhinavsingh717073@gmail.com>
Copilot AI review requested due to automatic review settings May 14, 2026 11:41
@volcano-sh-bot volcano-sh-bot added the kind/bug Something isn't working label May 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the garbage collection logic in pkg/workloadmanager/garbage_collection.go to deduplicate sandboxes from inactiveSandboxes and expiredSandboxes based on their SessionID. Feedback suggests simplifying the implementation by iterating over a slice of slices to reduce code duplication and adding nil checks for sandbox pointers to prevent potential panics.

Comment thread pkg/workloadmanager/garbage_collection.go Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 14, 2026

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

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.30%. Comparing base (524e55e) to head (a4b3e6f).
⚠️ Report is 54 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
+ Coverage   47.57%   49.30%   +1.73%     
==========================================
  Files          30       30              
  Lines        2819     2868      +49     
==========================================
+ Hits         1341     1414      +73     
+ Misses       1338     1301      -37     
- Partials      140      153      +13     
Flag Coverage Δ
unittests 49.30% <100.00%> (+1.73%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

…uce cyclomatic complexity

Signed-off-by: Abhinav Singh <abhinavsingh717073@gmail.com>
Signed-off-by: Abhinav Singh <abhinavsingh717073@gmail.com>
@Abhinav-kodes
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a deduplicateSandboxes utility function to merge and deduplicate sandbox lists by SessionID, preventing redundant processing when a sandbox meets multiple expiration criteria. The review feedback suggests adding a nil check for sandbox pointers within the deduplication loop to improve the function's robustness.

Comment thread pkg/workloadmanager/garbage_collection.go
Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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

The pull request process is described 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

@volcano-sh-bot volcano-sh-bot merged commit 3dba234 into volcano-sh:main May 19, 2026
14 checks passed
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.

5 participants