From cc580aaf6a315fbb2968d7a469fe84ea9452b7d9 Mon Sep 17 00:00:00 2001 From: lengrongfu <1275177125@qq.com> Date: Sun, 8 Oct 2023 14:53:53 +0000 Subject: [PATCH] add filter device-plugin validate container --- controllers/object_controls.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/controllers/object_controls.go b/controllers/object_controls.go index 385952da1..2d9e574fe 100644 --- a/controllers/object_controls.go +++ b/controllers/object_controls.go @@ -1963,16 +1963,6 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev if !strings.Contains(initContainer.Name, fmt.Sprintf("%s-validation", component)) { continue } - if component == "nvidia-fs" && (config.GPUDirectStorage == nil || !config.GPUDirectStorage.IsEnabled()) { - // remove nvidia-fs init container from validator Daemonset if GDS is not enabled - podSpec.InitContainers = append(podSpec.InitContainers[:i], podSpec.InitContainers[i+1:]...) - return nil - } - if component == "cc-manager" && !config.CCManager.IsEnabled() { - // remove cc-manager init container from validator Daemonset if it is not enabled - podSpec.InitContainers = append(podSpec.InitContainers[:i], podSpec.InitContainers[i+1:]...) - return nil - } // update validation image image, err := gpuv1.ImagePath(&config.Validator) if err != nil { @@ -2003,6 +1993,11 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev setContainerEnv(&(podSpec.InitContainers[i]), ValidatorRuntimeClassEnvName, *podSpec.RuntimeClassName) } case "plugin": + // remove plugin init container from validator Daemonset if it is not enabled + if !config.DevicePlugin.IsEnabled() { + podSpec.InitContainers = append(podSpec.InitContainers[:i], podSpec.InitContainers[i+1:]...) + return nil + } // set/append environment variables for plugin-validation container if len(config.Validator.Plugin.Env) > 0 { for _, env := range config.Validator.Plugin.Env { @@ -2030,9 +2025,17 @@ func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev } } case "nvidia-fs": - // no additional config required for nvidia-fs validation + if config.GPUDirectStorage == nil || !config.GPUDirectStorage.IsEnabled() { + // remove nvidia-fs init container from validator Daemonset if GDS is not enabled + podSpec.InitContainers = append(podSpec.InitContainers[:i], podSpec.InitContainers[i+1:]...) + return nil + } case "cc-manager": - // no additional config required for cc-manager validation + if !config.CCManager.IsEnabled() { + // remove cc-manager init container from validator Daemonset if it is not enabled + podSpec.InitContainers = append(podSpec.InitContainers[:i], podSpec.InitContainers[i+1:]...) + return nil + } case "toolkit": // set/append environment variables for toolkit-validation container if len(config.Validator.Toolkit.Env) > 0 {