diff --git a/ray-operator/apis/ray/v1alpha1/zz_generated.deepcopy.go b/ray-operator/apis/ray/v1alpha1/zz_generated.deepcopy.go index 33c8cec5f7..24f1087878 100644 --- a/ray-operator/apis/ray/v1alpha1/zz_generated.deepcopy.go +++ b/ray-operator/apis/ray/v1alpha1/zz_generated.deepcopy.go @@ -143,6 +143,21 @@ func (in *HeadGroupSpec) DeepCopy() *HeadGroupSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HeadInfo) DeepCopyInto(out *HeadInfo) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HeadInfo. +func (in *HeadInfo) DeepCopy() *HeadInfo { + if in == nil { + return nil + } + out := new(HeadInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RayActorOptionSpec) DeepCopyInto(out *RayActorOptionSpec) { *out = *in @@ -284,6 +299,7 @@ func (in *RayClusterStatus) DeepCopyInto(out *RayClusterStatus) { (*out)[key] = val } } + out.Head = in.Head } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RayClusterStatus. diff --git a/ray-operator/controllers/ray/common/pod_test.go b/ray-operator/controllers/ray/common/pod_test.go index c61db52ffe..94f8a7c95d 100644 --- a/ray-operator/controllers/ray/common/pod_test.go +++ b/ray-operator/controllers/ray/common/pod_test.go @@ -658,6 +658,10 @@ func TestDefaultWorkerPodTemplateWithName(t *testing.T) { worker := cluster.Spec.WorkerGroupSpecs[0] worker.Template.ObjectMeta.Name = "ray-worker-test" podName := cluster.Name + DashSymbol + string(rayiov1alpha1.WorkerNode) + DashSymbol + worker.GroupName + DashSymbol + utils.FormatInt32(0) - podTemplateSpec := DefaultWorkerPodTemplate(*cluster, worker, podName, svcName, "6379") + expectedWorker := *worker.DeepCopy() + + // Pass a deep copy of worker (*worker.DeepCopy()) to prevent "worker" from updating. + podTemplateSpec := DefaultWorkerPodTemplate(*cluster, *worker.DeepCopy(), podName, svcName, "6379") assert.Equal(t, podTemplateSpec.ObjectMeta.Name, "") + assert.Equal(t, worker, expectedWorker) } diff --git a/ray-operator/controllers/ray/raycluster_controller.go b/ray-operator/controllers/ray/raycluster_controller.go index 1306467697..0399591632 100644 --- a/ray-operator/controllers/ray/raycluster_controller.go +++ b/ray-operator/controllers/ray/raycluster_controller.go @@ -510,7 +510,7 @@ func (r *RayClusterReconciler) reconcilePods(instance *rayiov1alpha1.RayCluster) var i int32 for i = 0; i < diff; i++ { r.Log.Info("reconcilePods", "creating worker for group", worker.GroupName, fmt.Sprintf("index %d", i), fmt.Sprintf("in total %d", diff)) - if err := r.createWorkerPod(*instance, worker); err != nil { + if err := r.createWorkerPod(*instance, *worker.DeepCopy()); err != nil { return err } }