From b99e3fbefd094a054841ca45ad779954184778c2 Mon Sep 17 00:00:00 2001 From: Harry Li Date: Wed, 5 Jun 2024 18:09:10 +0800 Subject: [PATCH] fix: unwrap some env variables (v1.EnvVar) --- controllers/object_controls.go | 54 +++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/controllers/object_controls.go b/controllers/object_controls.go index 9fd4f4ee9..6eea370f0 100644 --- a/controllers/object_controls.go +++ b/controllers/object_controls.go @@ -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) } } @@ -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) } } @@ -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 @@ -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 @@ -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) } } @@ -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) } } @@ -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) } } @@ -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) } } @@ -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) } } @@ -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 @@ -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) } } @@ -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) } } @@ -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. @@ -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. @@ -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": @@ -2122,7 +2122,7 @@ 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": @@ -2130,7 +2130,7 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev 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": @@ -2138,7 +2138,7 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev 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": @@ -2146,7 +2146,7 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev 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: @@ -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) } } @@ -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) } } @@ -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) } } @@ -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) } } @@ -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() { @@ -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) } } @@ -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) } } } @@ -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) } } }