From 1e6fe40c764950f1e801806b309d9bc8e21d339c Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 7 Mar 2023 16:17:49 +0200 Subject: [PATCH] Allow nvidia-container-runtime.modes.cdi.default-kind to be set This change allows the nvidia-container-runtime.modes.cdi.default-kind to be set in the toolkit-container. The NVIDIA_CONTAINER_RUNTIME_MODES_CDI_DEFAULT_KIND envvar is used. Signed-off-by: Evan Lezar --- tools/container/toolkit/toolkit.go | 31 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/container/toolkit/toolkit.go b/tools/container/toolkit/toolkit.go index c3153e97..e1ffb716 100644 --- a/tools/container/toolkit/toolkit.go +++ b/tools/container/toolkit/toolkit.go @@ -43,13 +43,16 @@ const ( ) type options struct { - DriverRoot string - DriverRootCtrPath string - ContainerRuntimeMode string - ContainerRuntimeDebug string - ContainerRuntimeLogLevel string - ContainerCLIDebug string - toolkitRoot string + DriverRoot string + DriverRootCtrPath string + + ContainerRuntimeMode string + ContainerRuntimeModesCdiDefaultKind string + ContainerRuntimeDebug string + ContainerRuntimeLogLevel string + + ContainerCLIDebug string + toolkitRoot string cdiOutputDir string cdiKind string @@ -129,6 +132,11 @@ func main() { Destination: &opts.ContainerRuntimeMode, EnvVars: []string{"NVIDIA_CONTAINER_RUNTIME_MODE"}, }, + &cli.StringFlag{ + Name: "nvidia-container-runtime-modes.cdi.default-kind", + Destination: &opts.ContainerRuntimeModesCdiDefaultKind, + EnvVars: []string{"NVIDIA_CONTAINER_RUNTIME_MODES_CDI_DEFAULT_KIND"}, + }, &cli.StringFlag{ Name: "nvidia-container-cli-debug", Usage: "Specify the location of the debug log file for the NVIDIA Container CLI", @@ -345,10 +353,11 @@ func installToolkitConfig(toolkitConfigPath string, nvidiaContainerCliExecutable // Set the debug options if selected debugOptions := map[string]string{ - "nvidia-container-runtime.debug": opts.ContainerRuntimeDebug, - "nvidia-container-runtime.log-level": opts.ContainerRuntimeLogLevel, - "nvidia-container-runtime.mode": opts.ContainerRuntimeMode, - "nvidia-container-cli.debug": opts.ContainerCLIDebug, + "nvidia-container-runtime.debug": opts.ContainerRuntimeDebug, + "nvidia-container-runtime.log-level": opts.ContainerRuntimeLogLevel, + "nvidia-container-runtime.mode": opts.ContainerRuntimeMode, + "nvidia-container-runtime.modes.cdi.default-kind": opts.ContainerRuntimeModesCdiDefaultKind, + "nvidia-container-cli.debug": opts.ContainerCLIDebug, } for key, value := range debugOptions { if value == "" {