@@ -57,16 +57,18 @@ import (
5757const (
5858 // DefaultContainerdConfigFile indicates default config file path for containerd
5959 DefaultContainerdConfigFile = "/etc/containerd/config.toml"
60+ // DefaultContainerdDropInConfigFile indicates default drop-in config file path for containerd
61+ DefaultContainerdDropInConfigFile = "/run/nvidia/toolkit/config/99-nvidia.toml"
6062 // DefaultContainerdSocketFile indicates default containerd socket file
6163 DefaultContainerdSocketFile = "/run/containerd/containerd.sock"
6264 // DefaultDockerConfigFile indicates default config file path for docker
6365 DefaultDockerConfigFile = "/etc/docker/daemon.json"
6466 // DefaultDockerSocketFile indicates default docker socket file
6567 DefaultDockerSocketFile = "/var/run/docker.sock"
66- // DefaultCRIOConfigFile indicates default config file path for cri-o.
67- // Note, config files in the drop-in directory, /etc/crio/crio.conf.d,
68- // have a higher priority than the default /etc/crio/crio.conf file.
69- DefaultCRIOConfigFile = "/etc/crio/crio.conf.d/99-nvidia.conf"
68+ // DefaultCRIOConfigFile indicates default config file path for cri-o. .
69+ DefaultCRIOConfigFile = " /etc/crio/config.toml"
70+ // DefaultCRIODropInConfigFile indicates the default path to the drop-in config file for cri-o
71+ DefaultCRIODropInConfigFile = "/etc/crio/crio.conf.d/99-nvidia.conf"
7072 // TrustedCAConfigMapName indicates configmap with custom user CA injected
7173 TrustedCAConfigMapName = "gpu-operator-trusted-ca"
7274 // TrustedCABundleFileName indicates custom user ca certificate filename
@@ -95,6 +97,8 @@ const (
9597 DefaultRuntimeSocketTargetDir = "/runtime/sock-dir/"
9698 // DefaultRuntimeConfigTargetDir represents target directory where runtime socket dirctory will be mounted
9799 DefaultRuntimeConfigTargetDir = "/runtime/config-dir/"
100+ // DefaultRuntimeDropInConfigTargetDir represents target directory where drop-in config directory will be mounted
101+ DefaultRuntimeDropInConfigTargetDir = "/runtime/config-dir.d/"
98102 // ValidatorImageEnvName indicates env name for validator image passed
99103 ValidatorImageEnvName = "VALIDATOR_IMAGE"
100104 // ValidatorImagePullPolicyEnvName indicates env name for validator image pull policy passed
@@ -1340,23 +1344,13 @@ func transformForRuntime(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec,
13401344 return fmt .Errorf ("error getting path to runtime config file: %v" , err )
13411345 }
13421346
1343- var configEnvvarName string
1344- switch runtime {
1345- case gpuv1 .Containerd .String ():
1346- configEnvvarName = "CONTAINERD_CONFIG"
1347- case gpuv1 .Docker .String ():
1348- configEnvvarName = "DOCKER_CONFIG"
1349- case gpuv1 .CRIO .String ():
1350- configEnvvarName = "CRIO_CONFIG"
1351- }
1352-
13531347 // Handle the top-level configs
13541348 if runtimeConfigFiles .topLevelConfigFile != "" {
13551349 sourceConfigFileName := path .Base (runtimeConfigFiles .topLevelConfigFile )
13561350 sourceConfigDir := path .Dir (runtimeConfigFiles .topLevelConfigFile )
13571351 containerConfigDir := DefaultRuntimeConfigTargetDir
13581352 setContainerEnv (mainContainer , "RUNTIME_CONFIG" , containerConfigDir + sourceConfigFileName )
1359- setContainerEnv (mainContainer , configEnvvarName , containerConfigDir + sourceConfigFileName )
1353+ setContainerEnv (mainContainer , runtimeConfigFiles . envvarName , containerConfigDir + sourceConfigFileName )
13601354
13611355 volMountConfigName := fmt .Sprintf ("%s-config" , runtime )
13621356 volMountConfig := corev1.VolumeMount {Name : volMountConfigName , MountPath : containerConfigDir }
@@ -1376,8 +1370,7 @@ func transformForRuntime(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec,
13761370 if runtimeConfigFiles .dropInConfigFile != "" && containerName != "nvidia-kata-manager" {
13771371 sourceConfigFileName := path .Base (runtimeConfigFiles .dropInConfigFile )
13781372 sourceConfigDir := path .Dir (runtimeConfigFiles .dropInConfigFile )
1379- // TODO: This should be a constant.
1380- containerConfigDir := "/runtime/config-dir.d/"
1373+ containerConfigDir := DefaultRuntimeDropInConfigTargetDir
13811374 setContainerEnv (mainContainer , "RUNTIME_DROP_IN_CONFIG" , containerConfigDir + sourceConfigFileName )
13821375 setContainerEnv (mainContainer , "RUNTIME_DROP_IN_CONFIG_HOST_PATH" , runtimeConfigFiles .dropInConfigFile )
13831376
@@ -2393,9 +2386,7 @@ func TransformNodeStatusExporter(obj *appsv1.DaemonSet, config *gpuv1.ClusterPol
23932386}
23942387
23952388type runtimeConfigFiles struct {
2396- // TODO: Add envvarName as a member here so that we don't have to query this
2397- // again.
2398- // envvarName string
2389+ envvarName string
23992390 topLevelConfigFile string
24002391 dropInConfigFile string
24012392}
@@ -2412,38 +2403,38 @@ func getRuntimeConfigFiles(c *corev1.Container, runtime string) (runtimeConfigFi
24122403 topLevelConfigFile : topLevelConfigFile ,
24132404 // Docker does not support drop-in files.
24142405 dropInConfigFile : "" ,
2406+ envvarName : "DOCKER_CONFIG" ,
24152407 }, nil
24162408 case gpuv1 .Containerd .String ():
24172409 topLevelConfigFile := DefaultContainerdConfigFile
24182410 // TODO: We should also read RUNTIME_CONFIG here
24192411 if value := getContainerEnv (c , "CONTAINERD_CONFIG" ); value != "" {
24202412 topLevelConfigFile = value
24212413 }
2422- // TODO: This should be a sane default.
2423- dropInConfigFile := "/run/toolkit/config/99-nvidia.toml"
2414+ dropInConfigFile := DefaultContainerdDropInConfigFile
24242415 if value := getContainerEnv (c , "RUNTIME_DROP_IN_CONFIG" ); value != "" {
24252416 dropInConfigFile = value
24262417 }
24272418 return runtimeConfigFiles {
24282419 topLevelConfigFile : topLevelConfigFile ,
24292420 dropInConfigFile : dropInConfigFile ,
2421+ envvarName : "CONTAINERD_CONFIG" ,
24302422 }, nil
24312423 case gpuv1 .CRIO .String ():
24322424 // TODO: We should still allow the top-level config to be specified
2433- // TODO: This should be DefaultCRIOConfigFile, but this is not the correct value.
24342425 // TODO: We should also read RUNTIME_CONFIG here
2435- topLevelConfigFile := "/etc/crio/config.toml"
2426+ topLevelConfigFile := DefaultCRIOConfigFile
24362427 if value := getContainerEnv (c , "CRIO_CONFIG" ); value != "" {
24372428 topLevelConfigFile = value
24382429 }
2439- // TODO: The constant should have a different name (e.g. DefaultCRIODropInFile)
2440- dropInConfigFile := DefaultCRIOConfigFile
2430+ dropInConfigFile := DefaultCRIODropInConfigFile
24412431 if value := getContainerEnv (c , "RUNTIME_DROP_IN_CONFIG" ); value != "" {
24422432 dropInConfigFile = value
24432433 }
24442434 return runtimeConfigFiles {
24452435 topLevelConfigFile : topLevelConfigFile ,
24462436 dropInConfigFile : dropInConfigFile ,
2437+ envvarName : "CRIO_CONFIG" ,
24472438 }, nil
24482439 default :
24492440 return runtimeConfigFiles {}, fmt .Errorf ("invalid runtime: %s" , runtime )
0 commit comments