From 9c2476c98d2d1414c26d7c93c7d4d4a8d4fed763 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 18 Sep 2024 22:20:56 +0200 Subject: [PATCH] Expose opt-in features in toolkit-container This change enables opt-in (off-by-default) features to be opted into. These features can be toggled by name by specifying the (repeated) --opt-in-feature command line argument or as a comma-separated list in the NVIDIA_CONTAINER_TOOLKIT_OPT_IN_FEATURES environment variable. Signed-off-by: Evan Lezar --- tools/container/toolkit/toolkit.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/container/toolkit/toolkit.go b/tools/container/toolkit/toolkit.go index 8175ed4e..c9d0db6a 100644 --- a/tools/container/toolkit/toolkit.go +++ b/tools/container/toolkit/toolkit.go @@ -81,6 +81,8 @@ type options struct { acceptNVIDIAVisibleDevicesAsVolumeMounts bool ignoreErrors bool + + optInFeatures cli.StringSlice } func main() { @@ -250,6 +252,12 @@ func main() { Destination: &opts.createDeviceNodes, EnvVars: []string{"CREATE_DEVICE_NODES"}, }, + &cli.StringSliceFlag{ + Name: "opt-in-feature", + Hidden: true, + Destination: &opts.optInFeatures, + EnvVars: []string{"NVIDIA_CONTAINER_TOOLKIT_OPT_IN_FEATURES"}, + }, } // Update the subcommand flags with the common subcommand flags @@ -518,6 +526,10 @@ func installToolkitConfig(c *cli.Context, toolkitConfigPath string, nvidiaContai "nvidia-container-runtime.runtimes": opts.ContainerRuntimeRuntimes, "nvidia-container-cli.debug": opts.ContainerCLIDebug, } + for _, feature := range opts.optInFeatures.Value() { + optionalConfigValues["features."+feature] = true + } + for key, value := range optionalConfigValues { if !c.IsSet(key) { log.Infof("Skipping unset option: %v", key)