Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tools/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Options struct {
SetAsDefault bool
RestartMode string
HostRootMount string

ConfigSources cli.StringSlice
}

// ParseArgs parses the command line arguments to the CLI
Expand Down
15 changes: 13 additions & 2 deletions tools/container/runtime/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,23 @@ func GetLowlevelRuntimePaths(o *container.Options, co *Options) ([]string, error
}

func getRuntimeConfig(o *container.Options, co *Options) (engine.Interface, error) {
var loaders []toml.Loader
for _, source := range o.ConfigSources.Value() {
switch source {
case "file":
loaders = append(loaders, toml.FromFile(o.Config))
case "command":
loaders = append(loaders, containerd.CommandLineSource(o.HostRootMount, o.ExecutablePath))
default:
// TODO: log a warning here.
}
}

return containerd.New(
containerd.WithPath(o.Config),
containerd.WithConfigSource(
toml.LoadFirst(
containerd.CommandLineSource(o.HostRootMount, o.ExecutablePath),
toml.FromFile(o.Config),
loaders...,
),
),
containerd.WithRuntimeType(co.runtimeType),
Expand Down
9 changes: 9 additions & 0 deletions tools/container/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ func Flags(opts *Options) []cli.Flag {
EnvVars: []string{"NVIDIA_RUNTIME_SET_AS_DEFAULT", "CONTAINERD_SET_AS_DEFAULT", "DOCKER_SET_AS_DEFAULT"},
Hidden: true,
},
&cli.StringSliceFlag{
Name: "config-source",
Usage: "specify the config sources",
Destination: &opts.ConfigSources,
EnvVars: []string{"RUNTIME_CONFIG_SOURCES"},
},
}

flags = append(flags, containerd.Flags(&opts.containerdOptions)...)
Expand Down Expand Up @@ -137,6 +143,9 @@ func (opts *Options) Validate(c *cli.Context, runtime string, toolkitRoot string
if opts.RestartMode == runtimeSpecificDefault {
opts.RestartMode = containerd.DefaultRestartMode
}
if len(opts.ConfigSources.Value()) == 0 {
_ = opts.ConfigSources.Set("command,file")
}
case crio.Name:
if opts.Config == runtimeSpecificDefault {
opts.Config = crio.DefaultConfig
Expand Down