Skip to content

Commit

Permalink
[kubectl-plugin] fix worker resources in 'kubectl ray create cluster'…
Browse files Browse the repository at this point in the history
… command (#2671)

Signed-off-by: Andrew Sy Kim <[email protected]>
  • Loading branch information
andrewsykim authored Dec 20, 2024
1 parent e96dedc commit 2c47bbc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions kubectl-plugin/pkg/util/generation/generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions kubectl-plugin/pkg/util/generation/generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func TestGenerateRayCluterApplyConfig(t *testing.T) {
HeadMemory: "5Gi",
WorkerGrpName: "worker-group1",
WorkerReplicas: 3,
WorkerCPU: "1",
WorkerMemory: "5Gi",
WorkerCPU: "2",
WorkerMemory: "10Gi",
},
}

Expand Down Expand Up @@ -52,8 +52,8 @@ func TestGenerateRayJobApplyConfig(t *testing.T) {
HeadMemory: "5Gi",
WorkerGrpName: "worker-group1",
WorkerReplicas: 3,
WorkerCPU: "1",
WorkerMemory: "5Gi",
WorkerCPU: "2",
WorkerMemory: "10Gi",
},
}

Expand Down Expand Up @@ -83,8 +83,8 @@ func TestConvertRayClusterApplyConfigToYaml(t *testing.T) {
HeadMemory: "5Gi",
WorkerGrpName: "worker-group1",
WorkerReplicas: 3,
WorkerCPU: "1",
WorkerMemory: "5Gi",
WorkerCPU: "2",
WorkerMemory: "10Gi",
},
}

Expand Down Expand Up @@ -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))
}

0 comments on commit 2c47bbc

Please sign in to comment.