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

add mnt pvc path to container #1123

Merged
merged 1 commit into from
Nov 21, 2019
Merged
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
11 changes: 7 additions & 4 deletions operator/controllers/model_initializer_injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func InjectModelInitializer(deployment *appsv1.Deployment, containerName string,
for _, container := range podSpec.InitContainers {
if strings.Compare(container.Name, ModelInitializerContainerName) == 0 {
// make sure we have the mount on the main container
addVolumeMountToContainer(userContainer, ModelInitializerVolumeName)
addVolumeMountToContainer(userContainer, ModelInitializerVolumeName, DefaultModelLocalMountPath)
return deployment, nil
}
}
Expand Down Expand Up @@ -170,6 +170,9 @@ func InjectModelInitializer(deployment *appsv1.Deployment, containerName string,
}
modelInitializerMounts = append(modelInitializerMounts, pvcSourceVolumeMount)

// Since the model path is linked from source pvc, userContainer also need to mount the pvc.
addVolumeMountToContainer(userContainer, PvcSourceMountName, PvcSourceMountPath)

// modify the sourceURI to point to the PVC path
srcURI = PvcSourceMountPath + "/" + pvcPath
}
Expand Down Expand Up @@ -225,7 +228,7 @@ func InjectModelInitializer(deployment *appsv1.Deployment, containerName string,
},
}

addVolumeMountToContainer(userContainer, ModelInitializerVolumeName)
addVolumeMountToContainer(userContainer, ModelInitializerVolumeName, DefaultModelLocalMountPath)
// Add volumes to the PodSpec
podSpec.Volumes = append(podSpec.Volumes, podVolumes...)

Expand Down Expand Up @@ -265,7 +268,7 @@ func InjectModelInitializer(deployment *appsv1.Deployment, containerName string,
return deployment, nil
}

func addVolumeMountToContainer(userContainer *corev1.Container, ModelInitializerVolumeName string) {
func addVolumeMountToContainer(userContainer *corev1.Container, ModelInitializerVolumeName string, MountPath string) {
mountFound := false
for _, v := range userContainer.VolumeMounts {
if v.Name == ModelInitializerVolumeName {
Expand All @@ -276,7 +279,7 @@ func addVolumeMountToContainer(userContainer *corev1.Container, ModelInitializer
// Add a mount the shared volume on the user-container, update the PodSpec
sharedVolumeReadMount := &corev1.VolumeMount{
Name: ModelInitializerVolumeName,
MountPath: DefaultModelLocalMountPath,
MountPath: MountPath,
ReadOnly: true,
}
userContainer.VolumeMounts = append(userContainer.VolumeMounts, *sharedVolumeReadMount)
Expand Down