Skip to content

Commit dc93962

Browse files
committed
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-features command line argument or as a comma-separated list in the NVIDIA_CONTAINER_TOOLKIT_OPT_IN_FEATURES environment variable. Signed-off-by: Evan Lezar <[email protected]>
1 parent a662c53 commit dc93962

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/container/toolkit/toolkit.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ type Options struct {
7979
acceptNVIDIAVisibleDevicesAsVolumeMounts bool
8080

8181
ignoreErrors bool
82+
83+
optInFeatures cli.StringSlice
8284
}
8385

8486
func Flags(opts *Options) []cli.Flag {
@@ -202,6 +204,12 @@ func Flags(opts *Options) []cli.Flag {
202204
Destination: &opts.createDeviceNodes,
203205
EnvVars: []string{"CREATE_DEVICE_NODES"},
204206
},
207+
&cli.StringSliceFlag{
208+
Name: "opt-in-features",
209+
Hidden: true,
210+
Destination: &opts.optInFeatures,
211+
EnvVars: []string{"NVIDIA_CONTAINER_TOOLKIT_OPT_IN_FEATURES"},
212+
},
205213
}
206214

207215
return flags
@@ -457,6 +465,10 @@ func installToolkitConfig(c *cli.Context, toolkitConfigPath string, nvidiaContai
457465
configValues["nvidia-container-runtime.runtimes"] = toolkitRuntimeList
458466
}
459467

468+
for _, optInFeature := range opts.optInFeatures.Value() {
469+
configValues["features."+optInFeature] = true
470+
}
471+
460472
for key, value := range configValues {
461473
cfg.Set(key, value)
462474
}
@@ -471,6 +483,7 @@ func installToolkitConfig(c *cli.Context, toolkitConfigPath string, nvidiaContai
471483
"nvidia-container-runtime.runtimes": opts.ContainerRuntimeRuntimes,
472484
"nvidia-container-cli.debug": opts.ContainerCLIDebug,
473485
}
486+
474487
for key, value := range optionalConfigValues {
475488
if !c.IsSet(key) {
476489
log.Infof("Skipping unset option: %v", key)

0 commit comments

Comments
 (0)