Skip to content

Commit 85dce4a

Browse files
committed
Add --no-runtime-config option to toolkit installer
This change adds a --no-runtime-config flag to the nvidia-ctk-installer. When specified, the configuration (and cleanup) of a supported runtime is skipped. This can be used in cases where a user has already configured the runtime for use with the NVIDIA Container Toolkit and no config modifications are required. Signed-off-by: Evan Lezar <[email protected]>
1 parent 04a4478 commit 85dce4a

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

cmd/nvidia-ctk-installer/container/runtime/runtime.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,13 @@ type Configurer interface {
228228
}
229229

230230
type runtime string
231+
type noopRuntimeConfigurer struct{}
231232

232233
// NewConfigurer is a factory method for creating a runtime configurer.
233-
func NewConfigurer(name string) Configurer {
234+
func NewConfigurer(name string, noConfigureRuntime bool) Configurer {
235+
if noConfigureRuntime {
236+
return &noopRuntimeConfigurer{}
237+
}
234238
return runtime(name)
235239
}
236240

@@ -272,3 +276,15 @@ func (r runtime) GetLowlevelRuntimePaths(opts *Options) ([]string, error) {
272276
return nil, fmt.Errorf("undefined runtime %v", r)
273277
}
274278
}
279+
280+
func (r noopRuntimeConfigurer) Cleanup(_ *cli.Command, _ *Options) error {
281+
return nil
282+
}
283+
284+
func (r noopRuntimeConfigurer) GetLowlevelRuntimePaths(_ *Options) ([]string, error) {
285+
return nil, nil
286+
}
287+
288+
func (r noopRuntimeConfigurer) Setup(_ *cli.Command, _ *Options) error {
289+
return nil
290+
}

cmd/nvidia-ctk-installer/main.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ type options struct {
3838
toolkitInstallDir string
3939

4040
noDaemon bool
41-
runtime string
4241
pidFile string
4342
sourceRoot string
4443
packageType string
4544

4645
toolkitOptions toolkit.Options
47-
runtimeOptions runtime.Options
46+
47+
noRuntimeConfig bool
48+
runtime string
49+
runtimeOptions runtime.Options
4850
}
4951

5052
func (o options) toolkitRoot() string {
@@ -103,10 +105,19 @@ func (a app) build() *cli.Command {
103105
Destination: &options.noDaemon,
104106
Sources: cli.EnvVars("NO_DAEMON"),
105107
},
108+
&cli.BoolFlag{
109+
Name: "no-runtime-config",
110+
Usage: "Disables the configuration of a container runtime. This is used in cases where the runtime has " +
111+
"already been configured for use with the toolkit, and the installer is only used to deploy the " +
112+
"components of the NVIDIA Container Toolkit.",
113+
Destination: &options.noRuntimeConfig,
114+
Sources: cli.EnvVars("NO_RUNTIME_CONFIG"),
115+
},
106116
&cli.StringFlag{
107-
Name: "runtime",
108-
Aliases: []string{"r"},
109-
Usage: "the runtime to setup on this node. One of {'docker', 'crio', 'containerd'}",
117+
Name: "runtime",
118+
Aliases: []string{"r"},
119+
Usage: "the runtime to setup on this node. One of {'docker', 'crio', 'containerd'}. " +
120+
"This setting is ignored if --no-runtime-config is specified.",
110121
Value: defaultRuntime,
111122
Destination: &options.runtime,
112123
Sources: cli.EnvVars("RUNTIME"),
@@ -181,9 +192,11 @@ func (a *app) validateFlags(c *cli.Command, o *options) error {
181192
if err := a.toolkit.ValidateOptions(&o.toolkitOptions); err != nil {
182193
return err
183194
}
195+
184196
if err := o.runtimeOptions.Validate(a.logger, c, o.runtime, o.toolkitRoot(), &o.toolkitOptions); err != nil {
185197
return err
186198
}
199+
187200
return nil
188201
}
189202

@@ -197,7 +210,7 @@ func (a *app) Run(c *cli.Command, o *options) error {
197210
}
198211
defer a.shutdown(o.pidFile)
199212

200-
runtimeConfigurer := runtime.NewConfigurer(o.runtime)
213+
runtimeConfigurer := runtime.NewConfigurer(o.runtime, o.noRuntimeConfig)
201214

202215
if len(o.toolkitOptions.ContainerRuntimeRuntimes) == 0 {
203216
lowlevelRuntimePaths, err := runtimeConfigurer.GetLowlevelRuntimePaths(&o.runtimeOptions)

0 commit comments

Comments
 (0)