Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonwang371 committed Nov 8, 2022
1 parent 33a2e83 commit fb1f485
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions ray-operator/controllers/ray/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,16 +709,10 @@ func convertParamMap(rayStartParams map[string]string) (s string) {
// Used for a /dev/shm memory mount for object store and for a /tmp/ray disk mount for autoscaler logs.
func addEmptyDir(container *v1.Container, pod *v1.Pod, volumeName string, volumeMountPath string, storageMedium v1.StorageMedium) {
if checkIfVolumeMounted(container, pod, volumeMountPath) {
log.Info("volume already mounted", "volume", volumeName, "path", volumeMountPath)
return
}

// 0) Skip adding the volume if it is already in the list of volumes
for _, volume := range container.VolumeMounts {
if volume.Name == volumeName && volume.MountPath == volumeMountPath {
return
}
}

// 1) If needed, create a Volume of type emptyDir and add it to Volumes.
if !checkIfVolumeExists(pod, volumeName) {
emptyDirVolume := makeEmptyDirVolume(container, volumeName, storageMedium)
Expand Down Expand Up @@ -762,12 +756,7 @@ func makeEmptyDirVolume(container *v1.Container, volumeName string, storageMediu
func checkIfVolumeMounted(container *v1.Container, pod *v1.Pod, volumeMountPath string) bool {
for _, mountedVol := range container.VolumeMounts {
if mountedVol.MountPath == volumeMountPath {
for _, podVolume := range pod.Spec.Volumes {
if mountedVol.Name == podVolume.Name {
// already mounted, nothing to do
return true
}
}
return true
}
}
return false
Expand Down

0 comments on commit fb1f485

Please sign in to comment.