[ray-operator] Clean up batch scheduler resources on suspend #4940
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 307 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.343
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4940"
general
weight: 0.35
Future-Outlier
Why are these changes needed?
When a RayJob is suspended, the reconciler deletes its RayCluster to release
compute resources. However, when gang scheduling is enabled, the Volcano
PodGroupfor a RayJob is owned by the RayJob itself, not by the RayCluster.As a result it is not garbage-collected when the cluster is deleted, and its
MinMember/MinResourcesstay at the pre-suspend values.Volcano keeps reserving that capacity against the queue for a job that no longer
has any running pods, so a suspended RayJob silently holds queue resources and
can block other jobs in the same queue.
The terminal (Complete/Failed) path already cleans this up via
batchSchedulerOnCompletion, but the Suspending/Retrying path did not.This PR:
CleanupOnCompletionin theSuspending/Retryingbranch, beforeStatus.RayClusterNameis reset(the cleanup relies on it to locate the PodGroup). With the cluster gone, the
PodGroup is recalculated to empty resources, so it no longer reserves queue
capacity.
Suspending, so the cleanup isretried instead of leaking the PodGroup once the status transitions to
Suspended(which is no longer requeued).cleanupBatchSchedulerResources, which returnsan error. The suspend path propagates it (requeue); the terminal path keeps the
previous log-and-continue behavior via
batchSchedulerOnCompletion, since aterminal RayJob is not requeued.
This is a no-op when no batch scheduler is configured (the default scheduler
performs no cleanup).
Related issue number
Closes #4939
Checks
- [x] Unit tests
- [x] Manual tests
- [ ] This PR is not tested :(
Unit test:
TestBatchSchedulerCleanupCalledWhenRayJobSuspendingcovers that thebatch scheduler cleanup is invoked on the Suspending/Retrying path, transitions
the status on success, and requeues (returns an error) without transitioning to
Suspended when cleanup fails.
Manual test: with
--batch-scheduler=volcano, ran a RayJob with a Volcano queue,then set
suspend: true. Before the change the RayJob's PodGroup remained withits old
MinMember/MinResources(still reserving queue capacity); after thechange the PodGroup is recalculated to empty resources on suspend.