@@ -57,16 +57,18 @@ import (
57
57
const (
58
58
// DefaultContainerdConfigFile indicates default config file path for containerd
59
59
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"
60
62
// DefaultContainerdSocketFile indicates default containerd socket file
61
63
DefaultContainerdSocketFile = "/run/containerd/containerd.sock"
62
64
// DefaultDockerConfigFile indicates default config file path for docker
63
65
DefaultDockerConfigFile = "/etc/docker/daemon.json"
64
66
// DefaultDockerSocketFile indicates default docker socket file
65
67
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"
70
72
// TrustedCAConfigMapName indicates configmap with custom user CA injected
71
73
TrustedCAConfigMapName = "gpu-operator-trusted-ca"
72
74
// TrustedCABundleFileName indicates custom user ca certificate filename
@@ -95,6 +97,8 @@ const (
95
97
DefaultRuntimeSocketTargetDir = "/runtime/sock-dir/"
96
98
// DefaultRuntimeConfigTargetDir represents target directory where runtime socket dirctory will be mounted
97
99
DefaultRuntimeConfigTargetDir = "/runtime/config-dir/"
100
+ // DefaultRuntimeDropInConfigTargetDir represents target directory where drop-in config directory will be mounted
101
+ DefaultRuntimeDropInConfigTargetDir = "/runtime/config-dir.d/"
98
102
// ValidatorImageEnvName indicates env name for validator image passed
99
103
ValidatorImageEnvName = "VALIDATOR_IMAGE"
100
104
// ValidatorImagePullPolicyEnvName indicates env name for validator image pull policy passed
@@ -1340,23 +1344,13 @@ func transformForRuntime(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec,
1340
1344
return fmt .Errorf ("error getting path to runtime config file: %v" , err )
1341
1345
}
1342
1346
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
-
1353
1347
// Handle the top-level configs
1354
1348
if runtimeConfigFiles .topLevelConfigFile != "" {
1355
1349
sourceConfigFileName := path .Base (runtimeConfigFiles .topLevelConfigFile )
1356
1350
sourceConfigDir := path .Dir (runtimeConfigFiles .topLevelConfigFile )
1357
1351
containerConfigDir := DefaultRuntimeConfigTargetDir
1358
1352
setContainerEnv (mainContainer , "RUNTIME_CONFIG" , containerConfigDir + sourceConfigFileName )
1359
- setContainerEnv (mainContainer , configEnvvarName , containerConfigDir + sourceConfigFileName )
1353
+ setContainerEnv (mainContainer , runtimeConfigFiles . envvarName , containerConfigDir + sourceConfigFileName )
1360
1354
1361
1355
volMountConfigName := fmt .Sprintf ("%s-config" , runtime )
1362
1356
volMountConfig := corev1.VolumeMount {Name : volMountConfigName , MountPath : containerConfigDir }
@@ -1376,8 +1370,7 @@ func transformForRuntime(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec,
1376
1370
if runtimeConfigFiles .dropInConfigFile != "" && containerName != "nvidia-kata-manager" {
1377
1371
sourceConfigFileName := path .Base (runtimeConfigFiles .dropInConfigFile )
1378
1372
sourceConfigDir := path .Dir (runtimeConfigFiles .dropInConfigFile )
1379
- // TODO: This should be a constant.
1380
- containerConfigDir := "/runtime/config-dir.d/"
1373
+ containerConfigDir := DefaultRuntimeDropInConfigTargetDir
1381
1374
setContainerEnv (mainContainer , "RUNTIME_DROP_IN_CONFIG" , containerConfigDir + sourceConfigFileName )
1382
1375
setContainerEnv (mainContainer , "RUNTIME_DROP_IN_CONFIG_HOST_PATH" , runtimeConfigFiles .dropInConfigFile )
1383
1376
@@ -2393,9 +2386,7 @@ func TransformNodeStatusExporter(obj *appsv1.DaemonSet, config *gpuv1.ClusterPol
2393
2386
}
2394
2387
2395
2388
type 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
2399
2390
topLevelConfigFile string
2400
2391
dropInConfigFile string
2401
2392
}
@@ -2412,38 +2403,38 @@ func getRuntimeConfigFiles(c *corev1.Container, runtime string) (runtimeConfigFi
2412
2403
topLevelConfigFile : topLevelConfigFile ,
2413
2404
// Docker does not support drop-in files.
2414
2405
dropInConfigFile : "" ,
2406
+ envvarName : "DOCKER_CONFIG" ,
2415
2407
}, nil
2416
2408
case gpuv1 .Containerd .String ():
2417
2409
topLevelConfigFile := DefaultContainerdConfigFile
2418
2410
// TODO: We should also read RUNTIME_CONFIG here
2419
2411
if value := getContainerEnv (c , "CONTAINERD_CONFIG" ); value != "" {
2420
2412
topLevelConfigFile = value
2421
2413
}
2422
- // TODO: This should be a sane default.
2423
- dropInConfigFile := "/run/toolkit/config/99-nvidia.toml"
2414
+ dropInConfigFile := DefaultContainerdDropInConfigFile
2424
2415
if value := getContainerEnv (c , "RUNTIME_DROP_IN_CONFIG" ); value != "" {
2425
2416
dropInConfigFile = value
2426
2417
}
2427
2418
return runtimeConfigFiles {
2428
2419
topLevelConfigFile : topLevelConfigFile ,
2429
2420
dropInConfigFile : dropInConfigFile ,
2421
+ envvarName : "CONTAINERD_CONFIG" ,
2430
2422
}, nil
2431
2423
case gpuv1 .CRIO .String ():
2432
2424
// 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.
2434
2425
// TODO: We should also read RUNTIME_CONFIG here
2435
- topLevelConfigFile := "/etc/crio/config.toml"
2426
+ topLevelConfigFile := DefaultCRIOConfigFile
2436
2427
if value := getContainerEnv (c , "CRIO_CONFIG" ); value != "" {
2437
2428
topLevelConfigFile = value
2438
2429
}
2439
- // TODO: The constant should have a different name (e.g. DefaultCRIODropInFile)
2440
- dropInConfigFile := DefaultCRIOConfigFile
2430
+ dropInConfigFile := DefaultCRIODropInConfigFile
2441
2431
if value := getContainerEnv (c , "RUNTIME_DROP_IN_CONFIG" ); value != "" {
2442
2432
dropInConfigFile = value
2443
2433
}
2444
2434
return runtimeConfigFiles {
2445
2435
topLevelConfigFile : topLevelConfigFile ,
2446
2436
dropInConfigFile : dropInConfigFile ,
2437
+ envvarName : "CRIO_CONFIG" ,
2447
2438
}, nil
2448
2439
default :
2449
2440
return runtimeConfigFiles {}, fmt .Errorf ("invalid runtime: %s" , runtime )
0 commit comments