Skip to content

Commit d0a6b46

Browse files
committed
Add support for RUNTIME=none to disable runtime config in the nvidia-container-toolkit
Signed-off-by: Evan Lezar <[email protected]>
1 parent 83cffd9 commit d0a6b46

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

controllers/object_controls.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,14 +1314,19 @@ func TransformToolkit(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n
13141314
}
13151315
}
13161316

1317-
if len(config.Toolkit.Env) > 0 {
1318-
for _, env := range config.Toolkit.Env {
1319-
setContainerEnv(toolkitMainContainer, env.Name, env.Value)
1317+
// configure runtime
1318+
runtime := n.runtime.String()
1319+
// Update the main container environment from the user-specified values.
1320+
for _, env := range config.Toolkit.Env {
1321+
if env.Name == "RUNTIME" {
1322+
// If the user has specified the runtime, we overide the detected
1323+
// value.
1324+
// TODO: Add logging.
1325+
runtime = env.Value
13201326
}
1327+
setContainerEnv(toolkitMainContainer, env.Name, env.Value)
13211328
}
13221329

1323-
// configure runtime
1324-
runtime := n.runtime.String()
13251330
err = transformForRuntime(obj, config, runtime, toolkitMainContainer)
13261331
if err != nil {
13271332
return fmt.Errorf("error transforming toolkit daemonset : %w", err)
@@ -1332,6 +1337,11 @@ func TransformToolkit(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n
13321337

13331338
func transformForRuntime(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, runtime string, container *corev1.Container) error {
13341339
setContainerEnv(container, "RUNTIME", runtime)
1340+
// If the user has explicitly requested 'none' as a runtime, we make no
1341+
// additional changes to the container.
1342+
if runtime == "none" {
1343+
return nil
1344+
}
13351345

13361346
if runtime == gpuv1.Containerd.String() {
13371347
// Set the runtime class name that is to be configured for containerd

0 commit comments

Comments
 (0)