apply necessary transforms if a custom driver install directory is configured
(obj *appsv1.DaemonSet, driverInstallDir string)
| 877 | |
| 878 | // apply necessary transforms if a custom driver install directory is configured |
| 879 | func 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 |
| 910 | func TransformGPUDiscoveryPlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n ClusterPolicyController) error { |