Skip to content

Commit f6f6282

Browse files
committed
Fallback to file for runtime config
This change ensures that we fall back to the previous behaviour of reading the existing config from the specified config file if extracting the current config from the command line fails. This fixes use cases where the containerd / crio executables are not available. Signed-off-by: Evan Lezar <[email protected]>
1 parent 8328180 commit f6f6282

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tools/container/runtime/containerd/containerd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine"
2727
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine/containerd"
28+
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/toml"
2829
"github.com/NVIDIA/nvidia-container-toolkit/tools/container"
2930
)
3031

@@ -116,7 +117,12 @@ func Cleanup(c *cli.Context, o *container.Options, co *Options) error {
116117

117118
cfg, err := containerd.New(
118119
containerd.WithPath(o.Config),
119-
containerd.WithConfigSource(containerd.CommandLineSource(o.HostRootMount)),
120+
containerd.WithConfigSource(
121+
toml.LoadFirst(
122+
containerd.CommandLineSource(o.HostRootMount),
123+
toml.FromFile(o.Config),
124+
),
125+
),
120126
containerd.WithRuntimeType(co.runtimeType),
121127
containerd.WithUseLegacyConfig(co.useLegacyConfig),
122128
containerd.WithContainerAnnotations(co.containerAnnotationsFromCDIPrefixes()...),

tools/container/runtime/crio/crio.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine"
2929
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine/crio"
3030
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/ocihook"
31+
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/toml"
3132
"github.com/NVIDIA/nvidia-container-toolkit/tools/container"
3233
)
3334

@@ -170,7 +171,12 @@ func cleanupConfig(o *container.Options) error {
170171

171172
cfg, err := crio.New(
172173
crio.WithPath(o.Config),
173-
crio.WithConfigSource(crio.CommandLineSource(o.HostRootMount)),
174+
crio.WithConfigSource(
175+
toml.LoadFirst(
176+
crio.CommandLineSource(o.HostRootMount),
177+
toml.FromFile(o.Config),
178+
),
179+
),
174180
)
175181
if err != nil {
176182
return fmt.Errorf("unable to load config: %v", err)

0 commit comments

Comments
 (0)