Skip to content

Conversation

@win5923
Copy link
Collaborator

@win5923 win5923 commented Nov 10, 2025

Why are these changes needed?

Currently, when users update a RayCluster spec (e.g., update the image), users must re-create the cluster or set spec.suspend to true and after all Pods are deleted and then set it back to false.

Ref: #2534 (comment)

Design doc: https://docs.google.com/document/d/1xQLm0-WQWD-FkufxBJYklOJGvVn4RLk0_vPjLD5ax7o/edit?usp=sharing

Changes

  • Add spec.upgradeStrategy field to RayCluster CRD
  • Supports two values:
    • Recreate: During upgrade, Recreate strategy will delete all existing pods before creating new ones.
    • None: No new pod will be created while the strategy is set to None

Implementation

  • Store hash of HeadGroupSpec.Template to head pod and workerGroup.Template to worker pod annotations during creation with ray.io/pod-template-hash
  • Compare stored hash with current head pod or worker pod template hash to detect changes and recreate all pods

I only compare the HeadGroupSpec.Template and workerGroup.Template because these define the pod-related configurations. The RayCluster.Spec contains many dynamic and component-specific settings (e.g., autoscaler configs, rayStartParams).

Example:

apiVersion: ray.io/v1
kind: RayCluster
metadata:
  name: raycluster-kuberay
spec:
  upgradeStrategy:
    type: Recreate
  rayVersion: '2.48.0'

Related issue number

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@win5923 win5923 marked this pull request as draft November 10, 2025 16:24
@win5923 win5923 force-pushed the raycluster-upgradeStrategy branch 6 times, most recently from 710166a to d261b0b Compare November 10, 2025 17:11
@win5923 win5923 changed the title [draft] Support recreate pods for RayCluster using RayClusterSpec [draft] Support recreate pods for RayCluster using RayClusterSpec.upgradeStrategy Nov 10, 2025
@win5923
Copy link
Collaborator Author

win5923 commented Nov 10, 2025

Hi @andrewsykim, I followed you previous comments to adding a spec.upgradeStrategy API to RayCluster. But for now. I'm concerned this approach may introduce some issues:

  1. Confusion with existing API: We already have upgradeStrategy for RayService. Adding another upgradeStrategy to RayCluster could be confusing for users and creates unclear separation of concerns.
  2. Breaking RayJob workflows: For RayJob, setting upgradeStrategy=Recreate on the RayCluster would cause pod recreation during job execution, leading to job interruption and loss of running jobs.

Maybe we can just add a feature gate instead of using spec.upgradeStrategy.type field in RayCluster to enable the recreate behavior. WDYT?

@andrewsykim
Copy link
Member

Maybe we can just add a feature gate instead of using spec.upgradeStrategy.type field in RayCluster to enable the recreate behavior. WDYT?

Feature gates are used to gate features that are in early development and not ready for wider adoption, it shouldn't be used to change the behavior of RayCluster because it will eventually be on by default (and forced on).

@andrewsykim
Copy link
Member

I think both of those concerns are valid, but I don't think this is a problem with separation of concerns as RayCluster is a building block for both RayService and RayJob. For those cases you mentioned, we should have validation to ensure RayCluster upgrade strategy cannot be set when used w/ RayJob and RayService

@win5923 win5923 force-pushed the raycluster-upgradeStrategy branch 7 times, most recently from 05b8108 to 7109cf1 Compare November 19, 2025 17:27
@win5923 win5923 changed the title [draft] Support recreate pods for RayCluster using RayClusterSpec.upgradeStrategy [Feature] Support recreate pods for RayCluster using RayClusterSpec.upgradeStrategy Nov 19, 2025
@win5923 win5923 force-pushed the raycluster-upgradeStrategy branch 2 times, most recently from 3d448e6 to 8bcce91 Compare November 19, 2025 18:26
@win5923 win5923 force-pushed the raycluster-upgradeStrategy branch from 8bcce91 to bf87764 Compare November 19, 2025 18:28
@win5923 win5923 marked this pull request as ready for review November 19, 2025 18:30
@win5923 win5923 force-pushed the raycluster-upgradeStrategy branch 2 times, most recently from c9d35b2 to 8d4c813 Compare November 20, 2025 17:03
@win5923 win5923 force-pushed the raycluster-upgradeStrategy branch 5 times, most recently from f3c1e04 to 2c5166d Compare November 20, 2025 18:26
Signed-off-by: win5923 <[email protected]>
@win5923 win5923 force-pushed the raycluster-upgradeStrategy branch from 2c5166d to 9359c5f Compare November 20, 2025 18:32
@win5923
Copy link
Collaborator Author

win5923 commented Nov 21, 2025

Hi @andrewsykim, PTAL, thanks.

Signed-off-by: win5923 <[email protected]>
@win5923 win5923 force-pushed the raycluster-upgradeStrategy branch from 99d114b to acd7739 Compare November 22, 2025 10:58
templateHash := ""
if hash, err := GeneratePodTemplateHash(instance.Spec.HeadGroupSpec.Template); err == nil {
templateHash = hash
}
Copy link
Contributor

@400Ping 400Ping Nov 25, 2025

Choose a reason for hiding this comment

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

Consider logging the error and returning it up the call stack so that reconciliation can be retried.

expectError: true,
errorMessage: "upgradeStrategy cannot be set when RayCluster is created by RayService",
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a unit test that also verifies that invalid strategy values.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants