@@ -33,6 +33,7 @@ import (
3333 "sigs.k8s.io/controller-runtime/pkg/client/fake"
3434
3535 gpuv1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1"
36+ "github.com/NVIDIA/gpu-operator/internal/utils"
3637)
3738
3839var mockClientMap map [string ]client.Client
@@ -377,8 +378,8 @@ func TestTransformForRuntime(t *testing.T) {
377378 input : NewDaemonset ().
378379 WithContainer (corev1.Container {Name : "test-ctr" }),
379380 expectedOutput : NewDaemonset ().
380- WithHostPathVolume ("containerd-config" , filepath .Dir (DefaultContainerdConfigFile ), newHostPathType (corev1 .HostPathDirectoryOrCreate )).
381- WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
381+ WithHostPathVolume ("containerd-config" , filepath .Dir (DefaultContainerdConfigFile ), utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
382+ WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
382383 WithHostPathVolume ("containerd-socket" , filepath .Dir (DefaultContainerdSocketFile ), nil ).
383384 WithContainer (corev1.Container {
384385 Name : "test-ctr" ,
@@ -410,8 +411,8 @@ func TestTransformForRuntime(t *testing.T) {
410411 },
411412 }),
412413 expectedOutput : NewDaemonset ().
413- WithHostPathVolume ("containerd-config" , filepath .Dir (DefaultContainerdConfigFile ), newHostPathType (corev1 .HostPathDirectoryOrCreate )).
414- WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
414+ WithHostPathVolume ("containerd-config" , filepath .Dir (DefaultContainerdConfigFile ), utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
415+ WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
415416 WithHostPathVolume ("containerd-socket" , filepath .Dir (DefaultContainerdSocketFile ), nil ).
416417 WithContainer (corev1.Container {
417418 Name : "test-ctr" ,
@@ -444,8 +445,8 @@ func TestTransformForRuntime(t *testing.T) {
444445 },
445446 }),
446447 expectedOutput : NewDaemonset ().
447- WithHostPathVolume ("containerd-config" , filepath .Dir (DefaultContainerdConfigFile ), newHostPathType (corev1 .HostPathDirectoryOrCreate )).
448- WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
448+ WithHostPathVolume ("containerd-config" , filepath .Dir (DefaultContainerdConfigFile ), utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
449+ WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
449450 WithHostPathVolume ("containerd-socket" , filepath .Dir (DefaultContainerdSocketFile ), nil ).
450451 WithContainer (corev1.Container {
451452 Name : "test-ctr" ,
@@ -472,8 +473,8 @@ func TestTransformForRuntime(t *testing.T) {
472473 runtime : gpuv1 .CRIO ,
473474 input : NewDaemonset ().WithContainer (corev1.Container {Name : "test-ctr" }),
474475 expectedOutput : NewDaemonset ().
475- WithHostPathVolume ("crio-config" , "/etc/crio" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
476- WithHostPathVolume ("crio-drop-in-config" , "/etc/crio/crio.conf.d" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
476+ WithHostPathVolume ("crio-config" , "/etc/crio" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
477+ WithHostPathVolume ("crio-drop-in-config" , "/etc/crio/crio.conf.d" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
477478 WithContainer (corev1.Container {
478479 Name : "test-ctr" ,
479480 Env : []corev1.EnvVar {
@@ -496,7 +497,7 @@ func TestTransformForRuntime(t *testing.T) {
496497 input : NewDaemonset ().
497498 WithContainer (corev1.Container {Name : "nvidia-kata-manager" }),
498499 expectedOutput : NewDaemonset ().
499- WithHostPathVolume ("containerd-config" , filepath .Dir (DefaultContainerdConfigFile ), newHostPathType (corev1 .HostPathDirectoryOrCreate )).
500+ WithHostPathVolume ("containerd-config" , filepath .Dir (DefaultContainerdConfigFile ), utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
500501 WithHostPathVolume ("containerd-socket" , filepath .Dir (DefaultContainerdSocketFile ), nil ).
501502 WithContainer (corev1.Container {
502503 Name : "nvidia-kata-manager" ,
@@ -519,7 +520,7 @@ func TestTransformForRuntime(t *testing.T) {
519520 runtime : gpuv1 .Docker ,
520521 input : NewDaemonset ().WithContainer (corev1.Container {Name : "test-ctr" }),
521522 expectedOutput : NewDaemonset ().
522- WithHostPathVolume ("docker-config" , filepath .Dir (DefaultDockerConfigFile ), newHostPathType (corev1 .HostPathDirectoryOrCreate )).
523+ WithHostPathVolume ("docker-config" , filepath .Dir (DefaultDockerConfigFile ), utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
523524 WithHostPathVolume ("docker-socket" , filepath .Dir (DefaultDockerSocketFile ), nil ).
524525 WithContainer (corev1.Container {
525526 Name : "test-ctr" ,
@@ -840,8 +841,8 @@ func TestTransformToolkit(t *testing.T) {
840841 {Name : "containerd-socket" , MountPath : "/runtime/sock-dir/" },
841842 },
842843 }).
843- WithHostPathVolume ("containerd-config" , "/etc/containerd" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
844- WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
844+ WithHostPathVolume ("containerd-config" , "/etc/containerd" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
845+ WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
845846 WithHostPathVolume ("containerd-socket" , "/run/containerd" , nil ).
846847 WithPullSecret ("pull-secret" ),
847848 },
@@ -919,8 +920,8 @@ func TestTransformToolkit(t *testing.T) {
919920 {Name : "containerd-socket" , MountPath : "/runtime/sock-dir/" },
920921 },
921922 }).
922- WithHostPathVolume ("containerd-config" , "/var/lib/rancher/k3s/agent/etc/containerd" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
923- WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
923+ WithHostPathVolume ("containerd-config" , "/var/lib/rancher/k3s/agent/etc/containerd" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
924+ WithHostPathVolume ("containerd-drop-in-config" , "/etc/containerd/conf.d" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
924925 WithHostPathVolume ("containerd-socket" , "/run/k3s/containerd" , nil ).
925926 WithPullSecret ("pull-secret" ),
926927 },
@@ -957,8 +958,8 @@ func TestTransformToolkit(t *testing.T) {
957958 {Name : "crio-drop-in-config" , MountPath : "/runtime/config-dir.d/" },
958959 },
959960 }).
960- WithHostPathVolume ("crio-config" , "/etc/crio" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
961- WithHostPathVolume ("crio-drop-in-config" , "/etc/crio/crio.conf.d" , newHostPathType (corev1 .HostPathDirectoryOrCreate )),
961+ WithHostPathVolume ("crio-config" , "/etc/crio" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
962+ WithHostPathVolume ("crio-drop-in-config" , "/etc/crio/crio.conf.d" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )),
962963 },
963964 {
964965 description : "transform nvidia-container-toolkit-ctr container, cri-o runtime, cdi disabled" ,
@@ -993,8 +994,8 @@ func TestTransformToolkit(t *testing.T) {
993994 {Name : "crio-drop-in-config" , MountPath : "/runtime/config-dir.d/" },
994995 },
995996 }).
996- WithHostPathVolume ("crio-config" , "/etc/crio" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
997- WithHostPathVolume ("crio-drop-in-config" , "/etc/crio/crio.conf.d" , newHostPathType (corev1 .HostPathDirectoryOrCreate )),
997+ WithHostPathVolume ("crio-config" , "/etc/crio" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
998+ WithHostPathVolume ("crio-drop-in-config" , "/etc/crio/crio.conf.d" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )),
998999 },
9991000 }
10001001
@@ -1120,8 +1121,8 @@ func TestTransformMPSControlDaemon(t *testing.T) {
11201121 daemonset : NewDaemonset ().
11211122 WithInitContainer (corev1.Container {Name : "mps-control-daemon-mounts" }).
11221123 WithContainer (corev1.Container {Name : "mps-control-daemon-ctr" }).
1123- WithHostPathVolume ("mps-root" , "/run/nvidia/mps" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
1124- WithHostPathVolume ("mps-shm" , "/run/nvidia/mps/shm" , newHostPathType (corev1 .HostPathDirectoryOrCreate )),
1124+ WithHostPathVolume ("mps-root" , "/run/nvidia/mps" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
1125+ WithHostPathVolume ("mps-shm" , "/run/nvidia/mps/shm" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )),
11251126 clusterPolicySpec : & gpuv1.ClusterPolicySpec {
11261127 DevicePlugin : gpuv1.DevicePluginSpec {
11271128 Repository : "nvcr.io" ,
@@ -1146,8 +1147,8 @@ func TestTransformMPSControlDaemon(t *testing.T) {
11461147 {Name : "NVIDIA_MIG_MONITOR_DEVICES" , Value : "all" },
11471148 },
11481149 }).
1149- WithHostPathVolume ("mps-root" , "/var/mps" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
1150- WithHostPathVolume ("mps-shm" , "/var/mps/shm" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
1150+ WithHostPathVolume ("mps-root" , "/var/mps" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
1151+ WithHostPathVolume ("mps-shm" , "/var/mps/shm" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
11511152 WithPullSecret ("secret" ).
11521153 WithRuntimeClassName ("nvidia" ),
11531154 },
@@ -1540,7 +1541,7 @@ func TestTransformKataManager(t *testing.T) {
15401541 {Name : "containerd-config" , MountPath : "/runtime/config-dir/" },
15411542 {Name : "containerd-socket" , MountPath : "/runtime/sock-dir/" },
15421543 },
1543- }).WithPullSecret ("pull-secret" ).WithPodAnnotations (map [string ]string {"nvidia.com/kata-manager.last-applied-hash" : "1929911998" }).WithHostPathVolume ("kata-artifacts" , "/var/lib/kata" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).WithHostPathVolume ("containerd-config" , "/etc/containerd" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).WithHostPathVolume ("containerd-socket" , "/run/containerd" , nil ),
1544+ }).WithPullSecret ("pull-secret" ).WithPodAnnotations (map [string ]string {"nvidia.com/kata-manager.last-applied-hash" : "1929911998" }).WithHostPathVolume ("kata-artifacts" , "/var/lib/kata" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).WithHostPathVolume ("containerd-config" , "/etc/containerd" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).WithHostPathVolume ("containerd-socket" , "/run/containerd" , nil ),
15441545 },
15451546 {
15461547 description : "transform kata manager with custom container runtime socket" ,
@@ -1594,8 +1595,8 @@ func TestTransformKataManager(t *testing.T) {
15941595 },
15951596 }).WithPullSecret ("pull-secret" ).
15961597 WithPodAnnotations (map [string ]string {"nvidia.com/kata-manager.last-applied-hash" : "1929911998" }).
1597- WithHostPathVolume ("kata-artifacts" , "/var/lib/kata" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
1598- WithHostPathVolume ("containerd-config" , "/var/lib/rancher/k3s/agent/etc/containerd" , newHostPathType (corev1 .HostPathDirectoryOrCreate )).
1598+ WithHostPathVolume ("kata-artifacts" , "/var/lib/kata" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
1599+ WithHostPathVolume ("containerd-config" , "/var/lib/rancher/k3s/agent/etc/containerd" , utils . HostPathTypePtr (corev1 .HostPathDirectoryOrCreate )).
15991600 WithHostPathVolume ("containerd-socket" , "/run/k3s/containerd" , nil ),
16001601 },
16011602 }
0 commit comments