Skip to content

Commit b322509

Browse files
[no-relnote] Add drop-in-config flag to nvidia-ctk cmd
Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
1 parent 3592084 commit b322509

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",
@@ -241,6 +250,15 @@ func (m command) validateFlags(config *config) error {
241250
}
242251
}
243252

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

@@ -347,7 +365,14 @@ func (c *config) getOutputConfigPath() string {
347365
if c.dryRun {
348366
return ""
349367
}
350-
return c.configFilePath
368+
var configFilePath string
369+
if c.runtime == "containerd" || c.runtime == "crio" {
370+
configFilePath = c.dropInConfigPath
371+
} else {
372+
configFilePath = c.configFilePath
373+
}
374+
375+
return configFilePath
351376
}
352377

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

0 commit comments

Comments
 (0)