Skip to content

Commit fdb10ab

Browse files
committed
[no-relnote] Get low-level runtimes consistently
We ensure that we use the same low-level runtimes regardless of the runtime engine being configured. This ensures consistent behaviour. Signed-off-by: Evan Lezar <[email protected]>
1 parent e76c157 commit fdb10ab

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

pkg/config/engine/containerd/config_v1.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ func (c *ConfigV1) AddRuntime(name string, path string, setAsDefault bool) error
3838

3939
config.Set("version", int64(1))
4040

41-
// 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.
42-
runtimeNamesForConfig := []string{"runc"}
43-
if name, ok := config.GetPath([]string{"plugins", "cri", "containerd", "default_runtime_name"}).(string); ok && name != "" {
44-
runtimeNamesForConfig = append(runtimeNamesForConfig, name)
45-
}
41+
runtimeNamesForConfig := engine.GetLowLevelRuntimes(c)
4642
for _, r := range runtimeNamesForConfig {
4743
options := config.GetSubtreeByPath([]string{"plugins", "cri", "containerd", "runtimes", r})
4844
if options == nil {

pkg/config/engine/containerd/config_v2.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package containerd
1919
import (
2020
"fmt"
2121

22+
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine"
2223
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/toml"
2324
)
2425

@@ -31,11 +32,7 @@ func (c *Config) AddRuntime(name string, path string, setAsDefault bool) error {
3132

3233
config.Set("version", int64(2))
3334

34-
// 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.
35-
runtimeNamesForConfig := []string{"runc"}
36-
if name, ok := config.GetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "default_runtime_name"}).(string); ok && name != "" {
37-
runtimeNamesForConfig = append(runtimeNamesForConfig, name)
38-
}
35+
runtimeNamesForConfig := engine.GetLowLevelRuntimes(c)
3936
for _, r := range runtimeNamesForConfig {
4037
options := config.GetSubtreeByPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "runtimes", r})
4138
if options == nil {

pkg/config/engine/crio/crio.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,7 @@ func (c *Config) AddRuntime(name string, path string, setAsDefault bool) error {
8181

8282
config := *c.Tree
8383

84-
// By default, we extract the runtime options from the settings of the runtime marked as the "default_runtime";
85-
// if this does not exist we get the options from the "runc" runtime.
86-
var runtimeNamesForConfig []string
87-
if name, ok := config.GetPath([]string{"crio", "runtime", "default_runtime"}).(string); ok && name != "" {
88-
runtimeNamesForConfig = append(runtimeNamesForConfig, name)
89-
}
90-
runtimeNamesForConfig = append(runtimeNamesForConfig, "runc", "crun")
84+
runtimeNamesForConfig := engine.GetLowLevelRuntimes(c)
9185
for _, r := range runtimeNamesForConfig {
9286
if options, ok := config.GetPath([]string{"crio", "runtime", "runtimes", r}).(*toml.Tree); ok {
9387
c.Logger.Debugf("using options from runtime %v: %v", r, options.String())

0 commit comments

Comments
 (0)