Repository navigation
[ray-operator] Fail RayJob when the selected RayCluster is suspended - #5491
HsiaoHungKai wants to merge 5 commits into
Conversation
…ector is suspended A RayJob that uses clusterSelector waits in Initializing until the selected RayCluster becomes Ready. A suspended RayCluster (spec.suspend or spec.idleSuspend) never becomes Ready by itself, so the RayJob waits forever. Move the RayJob to Failed with the new reason SelectedRayClusterSuspended. The status message names the RayCluster and the suspend fields that are set. Signed-off-by: HungKai Hsiao <hsiaohungkai@gmail.com>
|
Failing fast is better than leaving a RayJob in
Proposal: keep this PR's failure for Worth covering in tests:
If mutating a selected cluster is considered inappropriate, the safer fallback is to keep the RayJob waiting rather than fail it, and show in its status that the cluster is idle-suspended, so another controller can resume it. AI assistance: Claude Opus 5.5. |
|
@elyall Thanks for the review! I’d like to keep failing on |
|
Thanks, the ownership concern is fair. I agree the RayJob controller shouldn't mutate a selected RayCluster, so I'll withdraw that part of the proposal. I still think failing on Could this PR fail only for The example in #5476 is exactly a shared cluster with @machichima, would failing only for |
|
I think by design #5210 we require user to change cc author of idle termination @win5923 @justinyeh1995 for your thoughts |
|
My understanding of @elyall's proposal is to let RayJob stays in Initialising status if the RayCluster is idle suspended, and let the RayCluster owner patch the |
|
@elyall @justinyeh1995 My understanding is that clusterSelector is meant to target a cluster that's already running. kuberay/ray-operator/apis/ray/v1/rayjob_types.go Lines 226 to 228 in 91f1833 I understand the concern about the RayJob failing right away, but I think that's the expected outcome here, since the selected cluster isn't running.
The failure is cheap to recover from, because the job hasn't been submitted yet. Users can patch idleSuspend back to false to resume the cluster, then resubmit the RayJob. |
|
SG. I think your point is valid. |
|
After discussing with @kevin85421 offline, we do not plan to add auto un-suspend to RayCluster. Users should be the ones to un-suspend it on their own. |
| { | ||
| // BackoffLimit is incompatible with ClusterSelector mode, so the RayJob must not retry. | ||
| name: "selected cluster is suspended and backoffLimit is 0", | ||
| clusterSuspend: new(true), | ||
| backoffLimit: new(int32(0)), | ||
| expectedStatus: rayv1.JobDeploymentStatusFailed, | ||
| expectedReason: rayv1.SelectedRayClusterSuspended, | ||
| }, |
There was a problem hiding this comment.
Curious about the reason to check backoffLimit here. it doesn't seem connected to the changes in this pr, and backoffLimit: 0 already disables retries, so it's a bit redundant.
There was a problem hiding this comment.
Thanks! My intent was to show the RayJob doesn’t retry in ClusterSelector mode, but backoffLimit > 0 is already rejected by validation and covered in validation_test.go, so this case was redundant. Removed it in dee6c86
Signed-off-by: HungKai Hsiao <hsiaohungkai@gmail.com>
…n-suspended-selected-cluster Signed-off-by: HungKai Hsiao <hsiaohungkai@gmail.com> # Conflicts: # ray-operator/controllers/ray/rayjob_controller_unit_test.go
Signed-off-by: HungKai Hsiao <hsiaohungkai@gmail.com>
justinyeh1995
left a comment
There was a problem hiding this comment.
LGTM. left a small nit.
| logger.Info("The RayCluster selected by clusterSelector is suspended. Transition the status to `Failed`.", "RayCluster", rayCluster.Namespace+"/"+rayCluster.Name, "suspendFields", suspendFields) | ||
| rayJob.Status.JobDeploymentStatus = rayv1.JobDeploymentStatusFailed | ||
| rayJob.Status.Reason = rayv1.SelectedRayClusterSuspended | ||
| rayJob.Status.Message = fmt.Sprintf("The RayCluster %s/%s selected by clusterSelector is suspended (%s), so it cannot run the RayJob.", rayCluster.Namespace, rayCluster.Name, strings.Join(suspendFields, ", ")) |
There was a problem hiding this comment.
nit: can we add a hint at the end of the message so users know how to recover? For example,
rayJob.Status.Message = fmt.Sprintf("The RayCluster %s/%s ... Resume the RayCluster and resubmit the RayJob.", rayCluster.Namespace, rayCluster.Name, strings.Join(suspendFields, ", "))WDYT?
There was a problem hiding this comment.
Thanks! The message now ends with "Resume the RayCluster and resubmit the RayJob." in 13b3892. I think this is a nice improvement. Users can now see both why the RayJob failed and how to fix it.
Signed-off-by: HungKai Hsiao <hsiaohungkai@gmail.com>
|
cc @CheyuWu This PR has been approved by @justinyeh1995. Could you take a look when you have time? Thanks! |
Why are these changes needed?
A RayJob that uses
clusterSelectorstays inInitializinguntil the selected RayCluster isReady. If that RayCluster hasspec.suspend=trueorspec.idleSuspend=true, it never becomesReadyby itself. The RayJob then stays inInitializingforever, and nothing tells the user why.This PR adds a check in the
Initializingstep, before the controller waits for the RayCluster to be ready. The check is in a new helper,checkSelectedClusterSuspendedAndUpdateStatusIfNeeded. The helper does these things:clusterSelector. RayJobs that create their own RayCluster do not change.jobDeploymentStatustoFailedwhen the selected RayCluster hasspec.suspendorspec.idleSuspendset.SelectedRayClusterSuspended. The status message names the RayCluster and lists which suspend fields are set.Related issue number
Closes #5476
Labels
doc-updates-requiredlabel.breaking-changelabel.AI assistance
Yes. I used Claude Code to help write the code and this description. I read every changed line myself.
Checks
How I tested
golangci-lint reports 1 existing issue not from this PR (gofumpt, rayjob_controller_test.go:203).