MCPcopy Index your code
hub / github.com/NVIDIA/gpu-operator / transformForDriverInstallDir

Function transformForDriverInstallDir

controllers/object_controls.go:879–907  ·  view source on GitHub ↗

apply necessary transforms if a custom driver install directory is configured

(obj *appsv1.DaemonSet, driverInstallDir string)

Source from the content-addressed store, hash-verified

877
878// apply necessary transforms if a custom driver install directory is configured
879func transformForDriverInstallDir(obj *appsv1.DaemonSet, driverInstallDir string) {
880 if driverInstallDir == "" || driverInstallDir == DefaultDriverInstallDir {
881 return
882 }
883
884 containsDriverInstallDirVolume := false
885 podSpec := obj.Spec.Template.Spec
886 for _, volume := range podSpec.Volumes {
887 if volume.Name == "driver-install-dir" {
888 volume.HostPath.Path = driverInstallDir
889 containsDriverInstallDirVolume = true
890 break
891 }
892 }
893
894 if !containsDriverInstallDirVolume {
895 return
896 }
897
898 if ctr := findContainerByName(podSpec.InitContainers, "driver-validation"); ctr != nil {
899 setContainerEnv(ctr, DriverInstallDirEnvName, driverInstallDir)
900 setContainerEnv(ctr, DriverInstallDirCtrPathEnvName, driverInstallDir)
901 for i, volumeMount := range ctr.VolumeMounts {
902 if volumeMount.Name == "driver-install-dir" {
903 ctr.VolumeMounts[i].MountPath = driverInstallDir
904 }
905 }
906 }
907}
908
909// TransformGPUDiscoveryPlugin transforms GPU discovery daemonset with required config as per ClusterPolicy
910func TransformGPUDiscoveryPlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n ClusterPolicyController) error {

Callers 2

preProcessDaemonSetFunction · 0.85

Calls 2

findContainerByNameFunction · 0.85
setContainerEnvFunction · 0.85

Tested by 1