Skip to content

Commit

Permalink
fixup: address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
davidxia committed Jul 5, 2022
1 parent 4a7ad6e commit 635ca71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions ray-operator/controllers/ray/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const (
RayLogVolumeMountPath = "/tmp/ray"
AutoscalerContainerName = "autoscaler"
RayHeadContainer = "ray-head"
objectStoreMemoryKey = "object-store-memory"
// TODO (dxia): should be a const in upstream ray-project/ray
allowSlowStorageEnvVar = "RAY_OBJECT_STORE_ALLOW_SLOW_STORAGE"
ObjectStoreMemoryKey = "object-store-memory"
// TODO (davidxia): should be a const in upstream ray-project/ray
AllowSlowStorageEnvVar = "RAY_OBJECT_STORE_ALLOW_SLOW_STORAGE"
)

var log = logf.Log.WithName("RayCluster-Controller")
Expand Down Expand Up @@ -564,22 +564,22 @@ func ValidateHeadRayStartParams(rayHeadGroupSpec rayiov1alpha1.HeadGroupSpec) (i
var objectStoreMemory int64
rayStartParams := rayHeadGroupSpec.RayStartParams
// validation for the object store memory
if objectStoreMemoryStr, ok := rayStartParams[objectStoreMemoryKey]; ok {
if objectStoreMemoryStr, ok := rayStartParams[ObjectStoreMemoryKey]; ok {
objectStoreMemory, err = strconv.ParseInt(objectStoreMemoryStr, 10, 64)
if err != nil {
isValid = false
err = errors.NewBadRequest(fmt.Sprintf("Cannot parse %s %s as an integer: %s", objectStoreMemoryKey, objectStoreMemoryStr, err.Error()))
err = errors.NewBadRequest(fmt.Sprintf("Cannot parse %s %s as an integer: %s", ObjectStoreMemoryKey, objectStoreMemoryStr, err.Error()))
return
}
for _, container := range rayHeadGroupSpec.Template.Spec.Containers {
// find the ray container.
if container.Name == RayHeadContainer {
if shmSize, ok := container.Resources.Requests.Memory().AsInt64(); ok && objectStoreMemory > shmSize {
if envVarExists(allowSlowStorageEnvVar, container.Env) {
if envVarExists(AllowSlowStorageEnvVar, container.Env) {
// in ray if this env var is set, it will only affect the performance.
isValid = true
msg := fmt.Sprintf("RayStartParams: object store memory exceeds head node container's memory request, %s:%d, memory request:%d\n"+
"This will harm performance. Consider deleting files in %s or increasing head node's memory request.", objectStoreMemoryKey, objectStoreMemory, shmSize, SharedMemoryVolumeMountPath)
"This will harm performance. Consider deleting files in %s or increasing head node's memory request.", ObjectStoreMemoryKey, objectStoreMemory, shmSize, SharedMemoryVolumeMountPath)
log.Info(msg)
err = errors.NewBadRequest(msg)
return
Expand All @@ -589,7 +589,7 @@ func ValidateHeadRayStartParams(rayHeadGroupSpec rayiov1alpha1.HeadGroupSpec) (i
msg := fmt.Sprintf("RayStartParams: object store memory exceeds head node container's memory request, %s:%d, memory request:%d\n"+
"This will lead to a ValueError in Ray! Consider deleting files in %s or increasing head node's memory request.\n"+
"To ignore this warning, set the following environment variable in headGroupSpec: %s=1",
objectStoreMemoryKey, objectStoreMemory, shmSize, SharedMemoryVolumeMountPath, allowSlowStorageEnvVar)
ObjectStoreMemoryKey, objectStoreMemory, shmSize, SharedMemoryVolumeMountPath, AllowSlowStorageEnvVar)
err = errors.NewBadRequest(msg)
return
}
Expand Down
6 changes: 3 additions & 3 deletions ray-operator/controllers/ray/common/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,9 @@ func TestValidateHeadRayStartParams_OK(t *testing.T) {

func TestValidateHeadRayStartParams_ValidWithObjectStoreMemoryError(t *testing.T) {
input := instance.Spec.HeadGroupSpec.DeepCopy()
input.RayStartParams["object-store-memory"] = "2000000000"
input.RayStartParams[ObjectStoreMemoryKey] = "2000000000"
input.Template.Spec.Containers[0].Env = append(input.Template.Spec.Containers[0].Env, v1.EnvVar{
Name: allowSlowStorageEnvVar,
Name: AllowSlowStorageEnvVar,
Value: "1",
})
isValid, err := ValidateHeadRayStartParams(*input)
Expand All @@ -478,7 +478,7 @@ func TestValidateHeadRayStartParams_ValidWithObjectStoreMemoryError(t *testing.T

func TestValidateHeadRayStartParams_InvalidObjectStoreMemory(t *testing.T) {
input := instance.Spec.HeadGroupSpec.DeepCopy()
input.RayStartParams["object-store-memory"] = "2000000000"
input.RayStartParams[ObjectStoreMemoryKey] = "2000000000"
isValid, err := ValidateHeadRayStartParams(*input)
assert.Equal(t, false, isValid)
assert.True(t, errors.IsBadRequest(err))
Expand Down

0 comments on commit 635ca71

Please sign in to comment.