Skip to content

Commit

Permalink
Always add 'config' emptyDir volume to GFD and device-plugin daemonsets
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Desiniotis <[email protected]>
  • Loading branch information
cdesiniotis committed Oct 25, 2024
1 parent d2c828b commit 2117822
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
10 changes: 10 additions & 0 deletions assets/gpu-feature-discovery/0500_daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ spec:
value: ""
- name: PROCESS_TO_SIGNAL
value: ""
volumeMounts:
- name: config
mountPath: /config
containers:
- image: "FILLED BY THE OPERATOR"
name: gpu-feature-discovery
Expand All @@ -127,6 +130,8 @@ spec:
- name: dmi-info-dir
mountPath: "/sys/class/dmi/id"
readOnly: true
- name: config
mountPath: /config
securityContext:
privileged: true
- image: "FILLED BY THE OPERATOR"
Expand Down Expand Up @@ -157,6 +162,9 @@ spec:
value: "1" # SIGHUP
- name: PROCESS_TO_SIGNAL
value: "gpu-feature-discovery"
volumeMounts:
- name: config
mountPath: /config
volumes:
- name: output-dir
hostPath:
Expand All @@ -175,3 +183,5 @@ spec:
hostPath:
path: /run/nvidia/driver
type: DirectoryOrCreate
- name: config
emptyDir: {}
10 changes: 10 additions & 0 deletions assets/state-device-plugin/0500_daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ spec:
value: ""
- name: PROCESS_TO_SIGNAL
value: ""
volumeMounts:
- name: config
mountPath: /config
containers:
- image: "FILLED BY THE OPERATOR"
name: nvidia-device-plugin
Expand Down Expand Up @@ -107,6 +110,8 @@ spec:
mountPath: /dev/shm
- name: mps-root
mountPath: /mps
- name: config
mountPath: /config
- image: "FILLED BY THE OPERATOR"
name: config-manager
command: ["config-manager"]
Expand Down Expand Up @@ -135,6 +140,9 @@ spec:
value: "1" # SIGHUP
- name: PROCESS_TO_SIGNAL
value: "nvidia-device-plugin"
volumeMounts:
- name: config
mountPath: /config
volumes:
- name: nvidia-device-plugin-entrypoint
configMap:
Expand Down Expand Up @@ -165,3 +173,5 @@ spec:
- name: mps-shm
hostPath:
path: /run/nvidia/mps/shm
- name: config
emptyDir: {}
17 changes: 2 additions & 15 deletions controllers/object_controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -2440,10 +2440,7 @@ func isCustomPluginConfigSet(pluginConfig *gpuv1.DevicePluginConfig) bool {

// adds shared volume mounts required for custom plugin config provided via a ConfigMap
func addSharedMountsForPluginConfig(container *corev1.Container, config *gpuv1.DevicePluginConfig) {
emptyDirMount := corev1.VolumeMount{Name: "config", MountPath: "/config"}
configVolMount := corev1.VolumeMount{Name: config.Name, MountPath: "/available-configs"}

container.VolumeMounts = append(container.VolumeMounts, emptyDirMount)
container.VolumeMounts = append(container.VolumeMounts, configVolMount)
}

Expand Down Expand Up @@ -2479,15 +2476,14 @@ func handleDevicePluginConfig(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicy
continue
}
setContainerEnv(&obj.Spec.Template.Spec.Containers[i], "CONFIG_FILE", "/config/config.yaml")
// setup sharedvolume(emptydir) for main container
// add configmap volume mount
addSharedMountsForPluginConfig(&obj.Spec.Template.Spec.Containers[i], config.DevicePlugin.Config)
}
// Enable process ns sharing for PID access
shareProcessNamespace := true
obj.Spec.Template.Spec.ShareProcessNamespace = &shareProcessNamespace
// setup volumes from configmap and shared emptyDir
// add configmap volume
obj.Spec.Template.Spec.Volumes = append(obj.Spec.Template.Spec.Volumes, createConfigMapVolume(config.DevicePlugin.Config.Name, nil))
obj.Spec.Template.Spec.Volumes = append(obj.Spec.Template.Spec.Volumes, createEmptyDirVolume("config"))

// apply env/volume changes to initContainer
err := transformConfigManagerInitContainer(obj, config)
Expand Down Expand Up @@ -3115,15 +3111,6 @@ func createConfigMapVolume(configMapName string, itemsToInclude []corev1.KeyToPa
return corev1.Volume{Name: configMapName, VolumeSource: volumeSource}
}

func createEmptyDirVolume(volumeName string) corev1.Volume {
return corev1.Volume{
Name: volumeName,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
}
}

func transformDriverContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n ClusterPolicyController) error {
driverIndex := 0
driverCtrFound := false
Expand Down

0 comments on commit 2117822

Please sign in to comment.