Skip to content

fix(framework): clean up Volcano PodGroup when TrainJob transitions to Failed - #4034

Open
Ayush-AM wants to merge 1 commit into
kubeflow:masterfrom
Ayush-AM:fix/issue-4033-volcano-podgroup-cleanup
Open

fix(framework): clean up Volcano PodGroup when TrainJob transitions to Failed#4034
Ayush-AM wants to merge 1 commit into
kubeflow:masterfrom
Ayush-AM:fix/issue-4033-volcano-podgroup-cleanup

Conversation

@Ayush-AM

@Ayush-AM Ayush-AM commented Sep 7, 2026

Copy link
Copy Markdown

What this PR does / why we need it:
When a Volcano-scheduled TrainJob transitions to the Failed condition (or reaches a terminal state), its associated scheduling.volcano.sh/v1beta1 PodGroup object was never deleted or cleaned up. Consequently, orphaned PodGroups remained in the cluster indefinitely, reserving minResources in Volcano scheduler queues and starving pending jobs.

This PR addresses the issue cleanly and modularly:

  1. Runtime Framework Extensibility: Introduced the TerminalCleanupPlugin interface (TerminalCleanup(ctx, trainJob) error) in pkg/runtime/framework so schedulers can clean up gang-scheduling resources on job completion without polluting the reconciler with vendor-specific logic.
  2. Volcano Plugin Implementation: Implemented TerminalCleanup in the Volcano plugin (pkg/runtime/framework/plugins/volcano). It looks up the PodGroup corresponding to the TrainJob, validates ownership via metav1.IsControlledBy(podGroup, trainJob), and deletes it idempotently (client.IgnoreNotFound).
  3. Controller Lifecycle Integration: Invoked r.Runtime.TerminalCleanup(ctx, &trainJob) in TrainJobReconciler.Reconcile() once trainjob.IsTrainJobFinished(&trainJob) is true.
  4. RBAC Updates: Added delete verb for scheduling.volcano.sh/podgroups in RBAC role definitions (manifests/base/rbac/role.yaml and charts/kubeflow-trainer/templates/rbac/clusterrole.yaml).
  5. Unit Tests: Added extensive unit tests across the Volcano plugin (TestVolcano_TerminalCleanup covering 6 test cases), Framework core (TestRunTerminalCleanupPlugins), and TrainJob reconciler (TestReconcile_TerminalCleanup verifying terminal cleanup on Failed and Complete jobs).

Which issue(s) this PR fixes:
Fixes #4033

Checklist:

  • Docs included if any changes are user facing (internal controller gang-scheduling cleanup; no user-facing API schema changes)

/assign @kuizhiqing @robert-bell
/cc @kuizhiqing @robert-bell

@google-oss-prow

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 gaocegege 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

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🎉 Welcome to the Kubeflow Trainer! 🎉

Thanks for opening your first PR! We're happy to have you as part of our community 🚀

Here's what happens next:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards.
  • Our team will review your PR soon! cc @kubeflow/kubeflow-trainer-team

Join the community:

Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏

…o Failed

When a Volcano-scheduled TrainJob transitions to a terminal state (such as Failed), its associated Volcano PodGroup was never cleaned up. This caused PodGroups to persist indefinitely in the cluster, reserving minResources in the Volcano queue and starving pending jobs.

To resolve this cleanly without tight coupling:
1. Introduced TerminalCleanupPlugin interface in runtime framework.
2. Implemented TerminalCleanup in the Volcano plugin to idempotently delete controlled PodGroups.
3. Updated RBAC definitions with delete verb on scheduling.volcano.sh/podgroups.
4. Invoked TerminalCleanup in TrainJobReconciler upon job completion/failure.
5. Added comprehensive unit tests across plugin, framework, and reconciler.

Closes kubeflow#4033

Signed-off-by: Ayush Mahajan <140263932+Ayush-AM@users.noreply.github.com>
@Ayush-AM
Ayush-AM force-pushed the fix/issue-4033-volcano-podgroup-cleanup branch from b1e5cc5 to a9836a9 Compare September 7, 2026 20:34
@Ayush-AM Ayush-AM changed the title fix(volcano): clean up PodGroup when TrainJob transitions to Failed fix(framework): clean up Volcano PodGroup when TrainJob transitions to Failed Sep 7, 2026
@Ayush-AM

Ayush-AM commented Sep 7, 2026

Copy link
Copy Markdown
Author

Hi @kuizhiqing @robert-bell! 👋

Submitted PR #4034 to fix issue #4033 ("Volcano PodGroup is not cleaned up when TrainJob transitions to Failed"):
#4034

All CI checks (PR title, DCO, and tests) are passing. Looking forward to your reviews! Thank you!

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

Labels

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

Volcano PodGroup is not cleaned up when TrainJob transitions to Failed

1 participant