Skip to content

Commit 9dc5067

Browse files
ArangoGutierrezelezar
authored andcommitted
[no-relnote] Add drop-in-config flag to nvidia-ctk cmd
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 96050da commit 9dc5067

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

cmd/nvidia-ctk/runtime/configure/configure.go

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ const (
4646
defaultCrioConfigFilePath = "/etc/crio/crio.conf"
4747
defaultDockerConfigFilePath = "/etc/docker/daemon.json"
4848

49+
defaultContainerdDropInConfigFilePath = "/etc/containerd/config.d/99-nvidia.toml"
50+
defaultCrioDropInConfigFilePath = "/etc/crio/conf.d/99-nvidia.toml"
51+
4952
defaultConfigSource = configSourceFile
5053
configSourceCommand = "command"
5154
configSourceFile = "file"
@@ -66,13 +69,14 @@ func NewCommand(logger logger.Interface) *cli.Command {
6669
// config defines the options that can be set for the CLI through config files,
6770
// environment variables, or command line config
6871
type config struct {
69-
dryRun bool
70-
runtime string
71-
configFilePath string
72-
executablePath string
73-
configSource string
74-
mode string
75-
hookFilePath string
72+
dryRun bool
73+
runtime string
74+
configFilePath string
75+
dropInConfigPath string
76+
executablePath string
77+
configSource string
78+
mode string
79+
hookFilePath string
7680

7781
nvidiaRuntime struct {
7882
name string
@@ -118,6 +122,11 @@ func (m command) build() *cli.Command {
118122
Usage: "path to the config file for the target runtime",
119123
Destination: &config.configFilePath,
120124
},
125+
&cli.StringFlag{
126+
Name: "drop-in-config",
127+
Usage: "path to the NVIDIA-specific config file to create. When specified, runtime configurations are saved to this file instead of modifying the main config file",
128+
Destination: &config.dropInConfigPath,
129+
},
121130
&cli.StringFlag{
122131
Name: "executable-path",
123132
Usage: "The path to the runtime executable. This is used to extract the current config",
@@ -240,6 +249,15 @@ func (m command) validateFlags(config *config) error {
240249
}
241250
}
242251

252+
if config.dropInConfigPath == "" && (config.runtime == "containerd" || config.runtime == "crio") {
253+
switch config.runtime {
254+
case "containerd":
255+
config.dropInConfigPath = defaultContainerdDropInConfigFilePath
256+
case "crio":
257+
config.dropInConfigPath = defaultCrioDropInConfigFilePath
258+
}
259+
}
260+
243261
return nil
244262
}
245263

@@ -346,7 +364,14 @@ func (c *config) getOutputConfigPath() string {
346364
if c.dryRun {
347365
return ""
348366
}
349-
return c.configFilePath
367+
var configFilePath string
368+
if c.runtime == "containerd" || c.runtime == "crio" {
369+
configFilePath = c.dropInConfigPath
370+
} else {
371+
configFilePath = c.configFilePath
372+
}
373+
374+
return configFilePath
350375
}
351376

352377
// configureOCIHook creates and configures the OCI hook for the NVIDIA runtime

0 commit comments

Comments
 (0)