Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong ray start command #431

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice catch. I think strings.ToLower(v) == "true" is not always correct for such cases. We internally use --dashboard-host directly and didn't notice this issue. The change looks good to me, we may leave an eye on new added flags in the future

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