Skip to content

Commit

Permalink
Merge pull request #741 from elezar/imex-default
Browse files Browse the repository at this point in the history
Add disableIMEXChannelCreation feature flag
  • Loading branch information
elezar authored Oct 17, 2024
2 parents ec8dfaf + 457d71c commit b077e26
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/nvidia-container-runtime-hook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func doPrestart() {
if cli.LoadKmods {
args = append(args, "--load-kmods")
}
if hook.Features.DisableImexChannelCreation.IsEnabled() {
args = append(args, "--no-create-imex-channels")
}
if cli.NoPivot {
args = append(args, "--no-pivot")
}
Expand Down
3 changes: 3 additions & 0 deletions internal/config/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ package config

// features specifies a set of named features.
type features struct {
// DisableImexChannelCreation ensures that the implicit creation of
// requested IMEX channels is skipped when invoking the nvidia-container-cli.
DisableImexChannelCreation *feature `toml:"disable-imex-channel-creation,omitempty"`
}

//nolint:unused
Expand Down
13 changes: 13 additions & 0 deletions tools/container/toolkit/toolkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type Options struct {
acceptNVIDIAVisibleDevicesAsVolumeMounts bool

ignoreErrors bool

optInFeatures cli.StringSlice
}

func Flags(opts *Options) []cli.Flag {
Expand Down Expand Up @@ -202,6 +204,12 @@ func Flags(opts *Options) []cli.Flag {
Destination: &opts.createDeviceNodes,
EnvVars: []string{"CREATE_DEVICE_NODES"},
},
&cli.StringSliceFlag{
Name: "opt-in-features",
Hidden: true,
Destination: &opts.optInFeatures,
EnvVars: []string{"NVIDIA_CONTAINER_TOOLKIT_OPT_IN_FEATURES"},
},
}

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

for _, optInFeature := range opts.optInFeatures.Value() {
configValues["features."+optInFeature] = true
}

for key, value := range configValues {
cfg.Set(key, value)
}
Expand All @@ -471,6 +483,7 @@ func installToolkitConfig(c *cli.Context, toolkitConfigPath string, nvidiaContai
"nvidia-container-runtime.runtimes": opts.ContainerRuntimeRuntimes,
"nvidia-container-cli.debug": opts.ContainerCLIDebug,
}

for key, value := range optionalConfigValues {
if !c.IsSet(key) {
log.Infof("Skipping unset option: %v", key)
Expand Down

0 comments on commit b077e26

Please sign in to comment.