Skip to content

Commit ecb07d1

Browse files
committed
Add ability to opt-out of containerd drop-in files
Signed-off-by: Christopher Desiniotis <[email protected]>
1 parent be415a8 commit ecb07d1

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ type Options struct {
5050
ContainerRuntimeModesCDIAnnotationPrefixes []string
5151

5252
runtimeConfigOverrideJSON string
53+
54+
disableDropInConfig bool
5355
}
5456

5557
func Flags(opts *Options) []cli.Flag {
@@ -82,6 +84,13 @@ func Flags(opts *Options) []cli.Flag {
8284
Value: "{}",
8385
Sources: cli.EnvVars("RUNTIME_CONFIG_OVERRIDE", "CONTAINERD_RUNTIME_CONFIG_OVERRIDE"),
8486
},
87+
&cli.BoolFlag{
88+
Name: "disable-drop-in-config",
89+
Usage: "Disable the use of drop-in config files. NVIDIA runtimes will be added to the top-level config file instead.",
90+
Value: false,
91+
Destination: &opts.disableDropInConfig,
92+
Sources: cli.EnvVars("CONTAINERD_DISABLE_DROP_IN_CONFIG"),
93+
},
8594
}
8695

8796
return flags
@@ -183,6 +192,7 @@ func getRuntimeConfig(o *container.Options, co *Options) (engine.Interface, erro
183192
containerd.WithRuntimeType(co.runtimeType),
184193
containerd.WithUseLegacyConfig(co.useLegacyConfig),
185194
containerd.WithContainerAnnotations(co.containerAnnotationsFromCDIPrefixes()...),
195+
containerd.WithDisableDropInConfig(co.disableDropInConfig),
186196
}
187197
if o.DropInConfigHostPath != "" && o.DropInConfig != "" {
188198
options = append(options,

pkg/config/engine/containerd/containerd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type configOptions struct {
5050
// for the CRI runtime service. The name of this plugin was changed in v3 of the
5151
// containerd configuration file.
5252
CRIRuntimePluginName string
53+
DisableDropInConfig bool
5354
}
5455

5556
var _ engine.Interface = (*Config)(nil)
@@ -122,6 +123,9 @@ func New(opts ...Option) (engine.Interface, error) {
122123
// We return the sourceConfig as is.
123124
return (*ConfigV1)(sourceConfig), nil
124125
default:
126+
if b.disableDropInConfig {
127+
return sourceConfig, nil
128+
}
125129
// For other versions, we create a DropInConfig with a reference to the
126130
// top-level config if present.
127131
topLevelConfig := &Config{

pkg/config/engine/containerd/option.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type builder struct {
3131
containerAnnotations []string
3232

3333
containerToHostPathMap map[string]string
34+
35+
disableDropInConfig bool
3436
}
3537

3638
// Option defines a function that can be used to configure the config builder
@@ -97,3 +99,10 @@ func WithContainerAnnotations(containerAnnotations ...string) Option {
9799
b.containerAnnotations = containerAnnotations
98100
}
99101
}
102+
103+
// WithDisableDropInConfig disables the use of drop-in config files
104+
func WithDisableDropInConfig(disable bool) Option {
105+
return func(b *builder) {
106+
b.disableDropInConfig = disable
107+
}
108+
}

0 commit comments

Comments
 (0)