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

Function preProcessDaemonSet

controllers/object_controls.go:728–781  ·  view source on GitHub ↗
(obj *appsv1.DaemonSet, n ClusterPolicyController)

Source from the content-addressed store, hash-verified

726}
727
728func preProcessDaemonSet(obj *appsv1.DaemonSet, n ClusterPolicyController) error {
729 logger := n.logger.WithValues("Daemonset", obj.Name)
730 transformations := map[string]func(*appsv1.DaemonSet, *gpuv1.ClusterPolicySpec, ClusterPolicyController) error{
731 "nvidia-driver-daemonset": TransformDriver,
732 "nvidia-vgpu-manager-daemonset": TransformVGPUManager,
733 "nvidia-vgpu-device-manager": TransformVGPUDeviceManager,
734 "nvidia-vfio-manager": TransformVFIOManager,
735 "nvidia-container-toolkit-daemonset": TransformToolkit,
736 "nvidia-device-plugin-daemonset": TransformDevicePlugin,
737 "nvidia-device-plugin-mps-control-daemon": TransformMPSControlDaemon,
738 "nvidia-sandbox-device-plugin-daemonset": TransformSandboxDevicePlugin,
739 "nvidia-kata-sandbox-device-plugin-daemonset": TransformKataDevicePlugin,
740 "nvidia-dcgm": TransformDCGM,
741 "nvidia-dcgm-exporter": TransformDCGMExporter,
742 "nvidia-node-status-exporter": TransformNodeStatusExporter,
743 "gpu-feature-discovery": TransformGPUDiscoveryPlugin,
744 "nvidia-mig-manager": TransformMIGManager,
745 "nvidia-operator-validator": TransformValidator,
746 "nvidia-sandbox-validator": TransformSandboxValidator,
747 "nvidia-kata-manager": TransformKataManager,
748 "nvidia-cc-manager": TransformCCManager,
749 }
750
751 t, ok := transformations[obj.Name]
752 if !ok {
753 logger.Info(fmt.Sprintf("No transformation for Daemonset '%s'", obj.Name))
754 return nil
755 }
756
757 // apply common Daemonset configuration that is applicable to all
758 err := applyCommonDaemonsetConfig(obj, &n.singleton.Spec)
759 if err != nil {
760 logger.Error(err, "Failed to apply common Daemonset transformation", "resource", obj.Name)
761 return err
762 }
763
764 // transform the host-root and host-dev-char volumes if a custom host root is configured with the operator
765 transformForHostRoot(obj, n.singleton.Spec.HostPaths.RootFS)
766
767 // transform the driver-root volume if a custom driver install dir is configured with the operator
768 transformForDriverInstallDir(obj, n.singleton.Spec.HostPaths.DriverInstallDir)
769
770 // apply per operand Daemonset config
771 err = t(obj, &n.singleton.Spec, n)
772 if err != nil {
773 logger.Error(err, "Failed to apply transformation", "resource", obj.Name)
774 return err
775 }
776
777 // apply custom Labels and Annotations to the podSpec if any
778 applyCommonDaemonsetMetadata(obj, &n.singleton.Spec.Daemonsets)
779
780 return nil
781}
782
783// applyCommonDaemonsetMetadata adds additional labels and annotations to the daemonset podSpec if there are any specified
784// by the user in the podSpec.

Callers 1

DaemonSetFunction · 0.85

Calls 5

transformForHostRootFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected