Skip to content

Commit 51d85df

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

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

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

Lines changed: 9 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,12 @@ 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+
Destination: &opts.DisableDropInConfig,
91+
Sources: cli.EnvVars("CONTAINERD_DISABLE_DROP_IN_CONFIG"),
92+
},
8593
}
8694

8795
return flags
@@ -183,6 +191,7 @@ func getRuntimeConfig(o *container.Options, co *Options) (engine.Interface, erro
183191
containerd.WithRuntimeType(co.runtimeType),
184192
containerd.WithUseLegacyConfig(co.useLegacyConfig),
185193
containerd.WithContainerAnnotations(co.containerAnnotationsFromCDIPrefixes()...),
194+
containerd.WithDisableDropInConfig(co.DisableDropInConfig),
186195
}
187196
if o.DropInConfigHostPath != "" && o.DropInConfig != "" {
188197
options = append(options,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ func (opts *Options) Validate(logger logger.Interface, c *cli.Command, runtime s
145145
opts.DropInConfig = ""
146146
}
147147
case containerd.Name:
148+
if opts.containerdOptions.DisableDropInConfig {
149+
opts.DropInConfig = ""
150+
}
148151
case crio.Name:
149152
if err := opts.crioOptions.Validate(logger, c); err != nil {
150153
return fmt.Errorf("invalid cri-o config: %w", err)

pkg/config/engine/containerd/containerd.go

Lines changed: 5 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,10 @@ 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+
b.logger.Info("Drop-in config files are disabled. Modifying the source config directly.")
128+
return sourceConfig, nil
129+
}
125130
// For other versions, we create a DropInConfig with a reference to the
126131
// top-level config if present.
127132
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)