mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Extract options from default runtime if runc does not exist
This change updates the logic to populate the options for the nvidia runtime configs added to containerd or crio from a default runtime if this is specified and a runc entry is not found. This allows the default runtime values for settings such as SystemdCgroup to be applied correctly. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -39,12 +39,22 @@ func (c *ConfigV1) AddRuntime(name string, path string, setAsDefault bool, confi
|
||||
|
||||
config.Set("version", int64(1))
|
||||
|
||||
if runc, ok := config.GetPath([]string{"plugins", "cri", "containerd", "runtimes", "runc"}).(*toml.Tree); ok {
|
||||
runc, _ = toml.Load(runc.String())
|
||||
config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name}, runc)
|
||||
// By default we extract the runtime options from the runc settings; if this does not exist we get the options from the default runtime specified in the config.
|
||||
runtimeNamesForConfig := []string{"runc"}
|
||||
if name, ok := config.GetPath([]string{"plugins", "cri", "containerd", "default_runtime_name"}).(string); ok && name != "" {
|
||||
runtimeNamesForConfig = append(runtimeNamesForConfig, name)
|
||||
}
|
||||
for _, r := range runtimeNamesForConfig {
|
||||
if options, ok := config.GetPath([]string{"plugins", "cri", "containerd", "runtimes", r}).(*toml.Tree); ok {
|
||||
c.Logger.Debugf("using options from runtime %v: %v", r, options.String())
|
||||
options, _ = toml.Load(options.String())
|
||||
config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name}, options)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if config.GetPath([]string{"plugins", "cri", "containerd", "runtimes", name}) == nil {
|
||||
c.Logger.Warningf("could not infer options from runtimes %v; using defaults", runtimeNamesForConfig)
|
||||
config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name, "runtime_type"}, c.RuntimeType)
|
||||
config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name, "runtime_root"}, "")
|
||||
config.SetPath([]string{"plugins", "cri", "containerd", "runtimes", name, "runtime_engine"}, "")
|
||||
|
||||
Reference in New Issue
Block a user