Skip to content

Commit

Permalink
fix: unwrap some env variables (v1.EnvVar)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayooot committed Jun 5, 2024
1 parent 56878e5 commit b99e3fb
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions controllers/object_controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ func TransformGPUDiscoveryPlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPol
// set/append environment variables for exporter container
if len(config.GPUFeatureDiscovery.Env) > 0 {
for _, env := range config.GPUFeatureDiscovery.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -1113,7 +1113,7 @@ func TransformToolkit(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n
// set/append environment variables for toolkit container
if len(config.Toolkit.Env) > 0 {
for _, env := range config.Toolkit.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -1254,7 +1254,7 @@ func TransformDevicePlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpe
// set/append environment variables for device-plugin container
if len(config.DevicePlugin.Env) > 0 {
for _, env := range config.DevicePlugin.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}
// add env to allow injection of /dev/nvidia-fs and /dev/infiniband devices for GDS
Expand Down Expand Up @@ -1413,7 +1413,7 @@ func TransformSandboxDevicePlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPo
// set/append environment variables for device-plugin container
if len(config.SandboxDevicePlugin.Env) > 0 {
for _, env := range config.SandboxDevicePlugin.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}
return nil
Expand Down Expand Up @@ -1455,7 +1455,7 @@ func TransformDCGMExporter(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpe
// set/append environment variables for exporter container
if len(config.DCGMExporter.Env) > 0 {
for _, env := range config.DCGMExporter.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -1584,7 +1584,7 @@ func TransformDCGM(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n Clu
// set/append environment variables for exporter container
if len(config.DCGM.Env) > 0 {
for _, env := range config.DCGM.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -1634,7 +1634,7 @@ func TransformMIGManager(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec,
// set/append environment variables for mig-manager container
if len(config.MIGManager.Env) > 0 {
for _, env := range config.MIGManager.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -1711,7 +1711,7 @@ func TransformKataManager(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec
// set/append environment variables for mig-manager container
if len(config.KataManager.Env) > 0 {
for _, env := range config.KataManager.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -1819,7 +1819,7 @@ func TransformVFIOManager(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec
// set/append environment variables for mig-manager container
if len(config.VFIOManager.Env) > 0 {
for _, env := range config.VFIOManager.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -1860,7 +1860,7 @@ func TransformCCManager(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec,
// set/append environment variables for cc-manager container
if len(config.CCManager.Env) > 0 {
for _, env := range config.CCManager.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}
// set default cc mode env
Expand Down Expand Up @@ -1911,7 +1911,7 @@ func TransformVGPUDeviceManager(obj *appsv1.DaemonSet, config *gpuv1.ClusterPoli
// set/append environment variables for mig-manager container
if len(config.VGPUDeviceManager.Env) > 0 {
for _, env := range config.VGPUDeviceManager.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -2031,7 +2031,7 @@ func TransformValidatorShared(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicy
// set/append environment variables for validator container
if len(config.Validator.Env) > 0 {
for _, env := range config.Validator.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -2060,7 +2060,7 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev
// set/append environment variables for cuda-validation container
if len(config.Validator.CUDA.Env) > 0 {
for _, env := range config.Validator.CUDA.Env {
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(podSpec.InitContainers[i]), env)
}
}
// set additional env to indicate image, pullSecrets to spin-off cuda validation workload pod.
Expand All @@ -2083,7 +2083,7 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev
// set/append environment variables for plugin-validation container
if len(config.Validator.Plugin.Env) > 0 {
for _, env := range config.Validator.Plugin.Env {
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(podSpec.InitContainers[i]), env)
}
}
// set additional env to indicate image, pullSecrets to spin-off plugin validation workload pod.
Expand All @@ -2103,7 +2103,7 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev
// set/append environment variables for driver-validation container
if len(config.Validator.Driver.Env) > 0 {
for _, env := range config.Validator.Driver.Env {
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(podSpec.InitContainers[i]), env)
}
}
case "nvidia-fs":
Expand All @@ -2122,31 +2122,31 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev
// set/append environment variables for toolkit-validation container
if len(config.Validator.Toolkit.Env) > 0 {
for _, env := range config.Validator.Toolkit.Env {
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(podSpec.InitContainers[i]), env)
}
}
case "vfio-pci":
// set/append environment variables for vfio-pci-validation container
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: "DEFAULT_GPU_WORKLOAD_CONFIG", Value: defaultGPUWorkloadConfig})
if len(config.Validator.VFIOPCI.Env) > 0 {
for _, env := range config.Validator.VFIOPCI.Env {
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(podSpec.InitContainers[i]), env)
}
}
case "vgpu-manager":
// set/append environment variables for vgpu-manager-validation container
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: "DEFAULT_GPU_WORKLOAD_CONFIG", Value: defaultGPUWorkloadConfig})
if len(config.Validator.VGPUManager.Env) > 0 {
for _, env := range config.Validator.VGPUManager.Env {
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(podSpec.InitContainers[i]), env)
}
}
case "vgpu-devices":
// set/append environment variables for vgpu-devices-validation container
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: "DEFAULT_GPU_WORKLOAD_CONFIG", Value: defaultGPUWorkloadConfig})
if len(config.Validator.VGPUDevices.Env) > 0 {
for _, env := range config.Validator.VGPUDevices.Env {
setContainerEnv(&(podSpec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(podSpec.InitContainers[i]), env)
}
}
default:
Expand Down Expand Up @@ -2196,7 +2196,7 @@ func TransformNodeStatusExporter(obj *appsv1.DaemonSet, config *gpuv1.ClusterPol
// set/append environment variables for exporter container
if len(config.NodeStatusExporter.Env) > 0 {
for _, env := range config.NodeStatusExporter.Env {
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env)
}
}

Expand Down Expand Up @@ -2498,7 +2498,7 @@ func transformDriverManagerInitContainer(obj *appsv1.DaemonSet, driverManagerSpe
// set/append environment variables for driver-manager initContainer
if len(driverManagerSpec.Env) > 0 {
for _, env := range driverManagerSpec.Env {
setContainerEnv(container, corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(container, env)
}
}

Expand Down Expand Up @@ -2594,7 +2594,7 @@ func transformGDSContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpe
// set/append environment variables for GDS container
if len(config.GPUDirectStorage.Env) > 0 {
for _, env := range config.GPUDirectStorage.Env {
setContainerEnv(gdsContainer, corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(gdsContainer, env)
}
}

Expand Down Expand Up @@ -2673,7 +2673,7 @@ func transformGDRCopyContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolic
// set/append environment variables for gdrcopy container
if len(config.GDRCopy.Env) > 0 {
for _, env := range config.GDRCopy.Env {
setContainerEnv(gdrcopyContainer, corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(gdrcopyContainer, env)
}
}

Expand Down Expand Up @@ -3076,7 +3076,7 @@ func transformDriverContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicy
// set/append environment variables for driver container
if len(config.Driver.Env) > 0 {
for _, env := range config.Driver.Env {
setContainerEnv(driverContainer, corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(driverContainer, env)
}
}
if config.Driver.OpenKernelModulesEnabled() {
Expand Down Expand Up @@ -3303,7 +3303,7 @@ func transformVGPUManagerContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterP
// set/append environment variables for exporter container
if len(config.VGPUManager.Env) > 0 {
for _, env := range config.VGPUManager.Env {
setContainerEnv(container, corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(container, env)
}
}

Expand Down Expand Up @@ -3363,7 +3363,7 @@ func transformValidationInitContainer(obj *appsv1.DaemonSet, config *gpuv1.Clust
if strings.HasPrefix(initContainer.Name, "driver") {
if len(config.Validator.Driver.Env) > 0 {
for _, env := range config.Validator.Driver.Env {
setContainerEnv(&(obj.Spec.Template.Spec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.InitContainers[i]), env)
}
}
}
Expand All @@ -3372,7 +3372,7 @@ func transformValidationInitContainer(obj *appsv1.DaemonSet, config *gpuv1.Clust
if strings.HasPrefix(initContainer.Name, "toolkit") {
if len(config.Validator.Toolkit.Env) > 0 {
for _, env := range config.Validator.Toolkit.Env {
setContainerEnv(&(obj.Spec.Template.Spec.InitContainers[i]), corev1.EnvVar{Name: env.Name, Value: env.Value})
setContainerEnv(&(obj.Spec.Template.Spec.InitContainers[i]), env)
}
}
}
Expand Down

0 comments on commit b99e3fb

Please sign in to comment.