[ray-operator] Add idleTerminationOptions for idle RayCluster termination - #5210
justinyeh1995 wants to merge 17 commits into
Conversation
…tion Signed-off-by: win5923 <ken89@kimo.com>
Signed-off-by: win5923 <ken89@kimo.com>
Signed-off-by: win5923 <ken89@kimo.com>
Signed-off-by: win5923 <ken89@kimo.com>
Signed-off-by: win5923 <ken89@kimo.com>
Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
…te; make sync Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
…on rule; new comment for types and make generate Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
e19faa4 to
9a34a0e
Compare
Signed-off-by: Justin Yeh <justinyeh1995@gmail.com>
Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
| } | ||
| } | ||
|
|
||
| return ctrl.Result{}, nil |
There was a problem hiding this comment.
Disabled feature leaves finalizer stuck
Medium Severity
The operator removes ray.io/no-driver-idle-termination only when IsIdleTerminationOptionsEnabled is true. If that finalizer is present but autoscaling or idleTerminationOptions has been turned off, deletion skips cleanup and the RayCluster stays Terminating forever.
Reviewed by Cursor Bugbot for commit 46bb176. Configure here.
Signed-off-by: justinyeh1995 <justinyeh1995@gmail.com>
46bb176 to
0b0eae5
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Reviewed by Cursor Bugbot for commit 0b0eae5. Configure here.
| APIGroups: []string{"ray.io"}, | ||
| Resources: []string{"rayclusters"}, | ||
| ResourceNames: []string{cluster.Name}, | ||
| Verbs: []string{"get", "patch", "delete"}, |
There was a problem hiding this comment.
Existing Roles omit delete permission
Medium Severity
BuildRole now grants delete (and scopes the rule with resourceNames), but reconcileAutoscalerRole still leaves an existing Role unchanged. Clusters created before this version never receive delete, so setting idleTerminationOptions.policy to Delete after upgrade fails with a 403 and the idle cluster is not removed.
Reviewed by Cursor Bugbot for commit 0b0eae5. Configure here.







Why are these changes needed?
The Ray Autoscaler can scale worker pods down to zero based on idleTimeoutSeconds, but the RayCluster custom resource and its associated resources still remain in the cluster. As a result, the head pod continues to consume resources and may reserve capacity even when the cluster is otherwise idle. Users who do not want to retain the head pod or its reserved capacity must manually delete the RayCluster.
With ray-project/ray#65763, the Ray Autoscaler automatically terminates an idle RayCluster when it has no attached user driver. This PR aims to implement KubeRay's side of the idle termination feature by introducing two apis, which are
idleSuspendandidleTerminationOptions.When
idleTerminationOptionsis set, the ray autoscaler will terminate an idle RayCluster. If the idleTerminationOptions.policy is Suspend, the ray autoscaler will patch idleSuspend=true, and the reconcile loop will recognize it and suspend the cluster same as how spec.Suspend works. The only difference is the reason emit in the event.On the other hand, when idleTerminationOptions.policy is Delete, the reconcile loop will log the event and remove the finalizer to allow the deletion.
Changes:
API and Constants
TimeoutSecondsandPolicytoIdleTerminationOptions.ray.io/no-driver-idle-terminationfinalizer andRayClusterIdleSuspendedcondition reason.Reconciliation
IdleSuspendas a suspension trigger and reuse the existing RayCluster suspend flow.RayClusterIdleSuspendedas the condition reason when suspension is triggered by idle termination.RBAC
Validation and Compatibility
IdleTerminationOptions.TimeoutSecondsis configured.(will be bumped to 2.59.0 once [Autoscaler] Support idleTerminationOptions for RayCluster idle termination ray#65763 is merged)
Related issue number
Closes #2998
Related PR #4932
Ray ray-project/ray#65763
Labels
doc-updates-requiredlabel.breaking-changelabel.Checks