From edcff28b2b41b4cca6f588a3ccbfa76828945331 Mon Sep 17 00:00:00 2001 From: ryandawsonuk Date: Wed, 20 Nov 2019 17:38:10 +0000 Subject: [PATCH] add mnt pvc path to container --- operator/controllers/model_initializer_injector.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/operator/controllers/model_initializer_injector.go b/operator/controllers/model_initializer_injector.go index 8fec1dcb79..3a148f1799 100644 --- a/operator/controllers/model_initializer_injector.go +++ b/operator/controllers/model_initializer_injector.go @@ -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 } } @@ -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 } @@ -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...) @@ -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 { @@ -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)