From 2c47bbc36741987c4de46998642c314e2bc4e083 Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Thu, 19 Dec 2024 20:26:09 -0500 Subject: [PATCH] [kubectl-plugin] fix worker resources in 'kubectl ray create cluster' command (#2671) Signed-off-by: Andrew Sy Kim --- .../pkg/util/generation/generation.go | 8 ++++---- .../pkg/util/generation/generation_test.go | 20 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kubectl-plugin/pkg/util/generation/generation.go b/kubectl-plugin/pkg/util/generation/generation.go index 61d714d698..e74bd7aaf3 100644 --- a/kubectl-plugin/pkg/util/generation/generation.go +++ b/kubectl-plugin/pkg/util/generation/generation.go @@ -90,12 +90,12 @@ func (rayClusterSpecObject *RayClusterSpecObject) generateRayClusterSpec() *rayv WithImage(rayClusterSpecObject.Image). WithResources(corev1ac.ResourceRequirements(). WithRequests(corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse(rayClusterSpecObject.HeadCPU), - corev1.ResourceMemory: resource.MustParse(rayClusterSpecObject.HeadMemory), + corev1.ResourceCPU: resource.MustParse(rayClusterSpecObject.WorkerCPU), + corev1.ResourceMemory: resource.MustParse(rayClusterSpecObject.WorkerMemory), }). WithLimits(corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse(rayClusterSpecObject.HeadCPU), - corev1.ResourceMemory: resource.MustParse(rayClusterSpecObject.HeadMemory), + corev1.ResourceCPU: resource.MustParse(rayClusterSpecObject.WorkerCPU), + corev1.ResourceMemory: resource.MustParse(rayClusterSpecObject.WorkerMemory), })))))) // Lifecycle cannot be empty, an empty lifecycle will stop pod startup so this will add lifecycle if its not empty diff --git a/kubectl-plugin/pkg/util/generation/generation_test.go b/kubectl-plugin/pkg/util/generation/generation_test.go index 09238a5246..9ac7709fb4 100644 --- a/kubectl-plugin/pkg/util/generation/generation_test.go +++ b/kubectl-plugin/pkg/util/generation/generation_test.go @@ -21,8 +21,8 @@ func TestGenerateRayCluterApplyConfig(t *testing.T) { HeadMemory: "5Gi", WorkerGrpName: "worker-group1", WorkerReplicas: 3, - WorkerCPU: "1", - WorkerMemory: "5Gi", + WorkerCPU: "2", + WorkerMemory: "10Gi", }, } @@ -52,8 +52,8 @@ func TestGenerateRayJobApplyConfig(t *testing.T) { HeadMemory: "5Gi", WorkerGrpName: "worker-group1", WorkerReplicas: 3, - WorkerCPU: "1", - WorkerMemory: "5Gi", + WorkerCPU: "2", + WorkerMemory: "10Gi", }, } @@ -83,8 +83,8 @@ func TestConvertRayClusterApplyConfigToYaml(t *testing.T) { HeadMemory: "5Gi", WorkerGrpName: "worker-group1", WorkerReplicas: 3, - WorkerCPU: "1", - WorkerMemory: "5Gi", + WorkerCPU: "2", + WorkerMemory: "10Gi", }, } @@ -133,11 +133,11 @@ spec: name: ray-worker resources: limits: - cpu: "1" - memory: 5Gi + cpu: "2" + memory: 10Gi requests: - cpu: "1" - memory: 5Gi` + cpu: "2" + memory: 10Gi` assert.Equal(t, expectedResultYaml, strings.TrimSpace(resultString)) }