-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option in toolkit container to enable CDI in runtime #838
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,3 +163,7 @@ func (c *ConfigV1) GetRuntimeConfig(name string) (engine.RuntimeConfig, error) { | |
tree: runtimeData, | ||
}, nil | ||
} | ||
|
||
func (c *ConfigV1) EnableCDI() { | ||
c.Set("enable_cdi", true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should be able to cast |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,13 +36,14 @@ const ( | |
|
||
// Options defines the shared options for the CLIs to configure containers runtimes. | ||
type Options struct { | ||
Config string | ||
Socket string | ||
RuntimeName string | ||
RuntimeDir string | ||
SetAsDefault bool | ||
RestartMode string | ||
HostRootMount string | ||
Config string | ||
Socket string | ||
RuntimeName string | ||
RuntimeDir string | ||
SetAsDefault bool | ||
RestartMode string | ||
HostRootMount string | ||
RuntimeEnableCDI bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't agree with the |
||
} | ||
|
||
// ParseArgs parses the command line arguments to the CLI | ||
|
@@ -111,6 +112,10 @@ func (o Options) UpdateConfig(cfg engine.Interface) error { | |
} | ||
} | ||
|
||
if o.RuntimeEnableCDI { | ||
cfg.EnableCDI() | ||
} | ||
|
||
return nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -30,8 +30,9 @@ import ( | |||||||||||||||||||
const ( | ||||||||||||||||||||
defaultSetAsDefault = true | ||||||||||||||||||||
// defaultRuntimeName specifies the NVIDIA runtime to be use as the default runtime if setting the default runtime is enabled | ||||||||||||||||||||
defaultRuntimeName = "nvidia" | ||||||||||||||||||||
defaultHostRootMount = "/host" | ||||||||||||||||||||
defaultRuntimeName = "nvidia" | ||||||||||||||||||||
defaultHostRootMount = "/host" | ||||||||||||||||||||
defaultRuntimeEnableCDI = false | ||||||||||||||||||||
|
||||||||||||||||||||
runtimeSpecificDefault = "RUNTIME_SPECIFIC_DEFAULT" | ||||||||||||||||||||
) | ||||||||||||||||||||
|
@@ -89,6 +90,13 @@ func Flags(opts *Options) []cli.Flag { | |||||||||||||||||||
EnvVars: []string{"NVIDIA_RUNTIME_SET_AS_DEFAULT", "CONTAINERD_SET_AS_DEFAULT", "DOCKER_SET_AS_DEFAULT"}, | ||||||||||||||||||||
Hidden: true, | ||||||||||||||||||||
}, | ||||||||||||||||||||
&cli.BoolFlag{ | ||||||||||||||||||||
Name: "runtime-enable-cdi", | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let the flag be passed as
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's try to be consistent with the option for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that we already have a nvidia-container-toolkit/tools/container/toolkit/toolkit.go Lines 173 to 179 in 8d869ac
Any ideas on what the name of the new flag should be? |
||||||||||||||||||||
Usage: "Enable CDI in the configured runtime", | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
Value: defaultRuntimeEnableCDI, | ||||||||||||||||||||
Destination: &opts.RuntimeEnableCDI, | ||||||||||||||||||||
EnvVars: []string{"RUNTIME_ENABLE_CDI"}, | ||||||||||||||||||||
}, | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
flags = append(flags, containerd.Flags(&opts.containerdOptions)...) | ||||||||||||||||||||
|
@@ -124,6 +132,9 @@ func ValidateOptions(opts *Options, runtime string, toolkitRoot string) error { | |||||||||||||||||||
if opts.RestartMode == runtimeSpecificDefault { | ||||||||||||||||||||
opts.RestartMode = crio.DefaultRestartMode | ||||||||||||||||||||
} | ||||||||||||||||||||
if opts.RuntimeEnableCDI { | ||||||||||||||||||||
opts.RuntimeEnableCDI = false | ||||||||||||||||||||
} | ||||||||||||||||||||
case docker.Name: | ||||||||||||||||||||
if opts.Config == runtimeSpecificDefault { | ||||||||||||||||||||
opts.Config = docker.DefaultConfig | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
Set
is only used to enable CDI. Let's remove that from the interface if that's the case.