Skip to content

Commit

Permalink
Fix wrong ray start command (ray-project#431)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw authored and Jeffwan committed Aug 9, 2022
1 parent 3b6f2fe commit 97ec8b2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ray-operator/controllers/ray/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,9 @@ func concatenateContainerCommand(nodeType rayiov1alpha1.RayNodeType, rayStartPar

func convertParamMap(rayStartParams map[string]string) (s string) {
flags := new(bytes.Buffer)
nonFlagParams := []string{"log-color", "include-dashboard"}
for k, v := range rayStartParams {
if strings.ToLower(v) == "true" {
if strings.ToLower(v) == "true" && !utils.Contains(nonFlagParams, k) {
fmt.Fprintf(flags, " --%s ", k)
} else {
fmt.Fprintf(flags, " --%s=%s ", k, v)
Expand Down
5 changes: 5 additions & 0 deletions ray-operator/controllers/ray/common/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var instance = rayiov1alpha1.RayCluster{
"object-store-memory": "100000000",
"redis-password": "LetMeInRay",
"num-cpus": "1",
"include-dashboard": "true",
"log-color": "true",
},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -562,6 +564,9 @@ func TestValidateHeadRayStartParams_OK(t *testing.T) {
isValid, err := ValidateHeadRayStartParams(*input)
assert.Equal(t, true, isValid)
assert.Nil(t, err)
command := convertParamMap(input.RayStartParams)
assert.True(t, strings.Contains(command, "--include-dashboard=true"))
assert.True(t, strings.Contains(command, "--log-color=true"))
}

func TestValidateHeadRayStartParams_ValidWithObjectStoreMemoryError(t *testing.T) {
Expand Down
11 changes: 7 additions & 4 deletions ray-operator/controllers/ray/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"math"
"reflect"
"sort"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -212,9 +211,13 @@ func CalculateAvailableReplicas(pods corev1.PodList) int32 {
return count
}

func Contains(s []string, searchTerm string) bool {
i := sort.SearchStrings(s, searchTerm)
return i < len(s) && s[i] == searchTerm
func Contains(elems []string, searchTerm string) bool {
for _, s := range elems {
if searchTerm == s {
return true
}
}
return false
}

func FilterContainerByName(containers []corev1.Container, name string) (corev1.Container, error) {
Expand Down

0 comments on commit 97ec8b2

Please sign in to comment.