mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Add cdi.enabled option to runtime configure
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -71,6 +71,11 @@ type config struct {
|
||||
hookPath string
|
||||
setAsDefault bool
|
||||
}
|
||||
|
||||
// cdi-specific options
|
||||
cdi struct {
|
||||
enabled bool
|
||||
}
|
||||
}
|
||||
|
||||
func (m command) build() *cli.Command {
|
||||
@@ -141,6 +146,11 @@ func (m command) build() *cli.Command {
|
||||
Usage: "set the NVIDIA runtime as the default runtime",
|
||||
Destination: &config.nvidiaRuntime.setAsDefault,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "cdi.enabled",
|
||||
Usage: "Enable CDI in the configured runtime",
|
||||
Destination: &config.cdi.enabled,
|
||||
},
|
||||
}
|
||||
|
||||
return &configure
|
||||
@@ -175,6 +185,13 @@ func (m command) validateFlags(c *cli.Context, config *config) error {
|
||||
}
|
||||
}
|
||||
|
||||
if config.runtime != "containerd" {
|
||||
if config.cdi.enabled {
|
||||
m.logger.Warningf("Ignoring cdi.enabled flag for %v", config.runtime)
|
||||
}
|
||||
config.cdi.enabled = false
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -227,6 +244,12 @@ func (m command) configureConfigFile(c *cli.Context, config *config) error {
|
||||
return fmt.Errorf("unable to update config: %v", err)
|
||||
}
|
||||
|
||||
if config.cdi.enabled {
|
||||
if err := cfg.Set("enable_cdi", true); err != nil {
|
||||
return fmt.Errorf("failed enable CDI in containerd: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
outputPath := config.getOuputConfigPath()
|
||||
n, err := cfg.Save(outputPath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user