Skip to content

Commit 3592084

Browse files
authored
Merge pull request #1314 from cdesiniotis/switch-default-crio-config-mode
Deprecate the hook config mode for cri-o
2 parents b3ce3a4 + 781bbe2 commit 3592084

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

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

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

2727
"github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk-installer/container"
2828
"github.com/NVIDIA/nvidia-container-toolkit/internal/config"
29+
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
2930
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine"
3031
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine/crio"
3132
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/ocihook"
@@ -35,7 +36,10 @@ import (
3536
const (
3637
Name = "crio"
3738

38-
defaultConfigMode = "hook"
39+
defaultConfigMode = configModeConfig
40+
41+
configModeConfig = "config"
42+
configModeHook = "hook"
3943

4044
// Hook-based settings
4145
defaultHooksDir = "/usr/share/containers/oci/hooks.d"
@@ -88,6 +92,16 @@ func Flags(opts *Options) []cli.Flag {
8892
return flags
8993
}
9094

95+
func (opts *Options) Validate(logger logger.Interface, _ *cli.Command) error {
96+
if opts.configMode != configModeConfig && opts.configMode != configModeHook {
97+
return fmt.Errorf("invalid cri-o config mode: %q", opts.configMode)
98+
}
99+
if opts.configMode == configModeHook {
100+
logger.Warningf("The %q config for cri-o is deprecated", opts.configMode)
101+
}
102+
return nil
103+
}
104+
91105
// Setup installs the prestart hook required to launch GPU-enabled containers
92106
func Setup(c *cli.Command, o *container.Options, co *Options) error {
93107
log.Infof("Starting 'setup' for %v", c.Name)

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

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

151154
// Apply the runtime-specific config changes.

cmd/nvidia-ctk/runtime/configure/configure.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,14 @@ func (m command) build() *cli.Command {
177177
}
178178

179179
func (m command) validateFlags(config *config) error {
180-
if config.mode == "oci-hook" {
180+
if config.mode == "oci-hook" || config.mode == "hook" {
181+
m.logger.Warningf("The %q config-mode is deprecated", config.mode)
181182
if !filepath.IsAbs(config.nvidiaRuntime.hookPath) {
182183
return fmt.Errorf("the NVIDIA runtime hook path %q is not an absolute path", config.nvidiaRuntime.hookPath)
183184
}
184185
return nil
185186
}
186-
if config.mode != "" && config.mode != "config-file" {
187+
if config.mode != "" && config.mode != "config-file" && config.mode != "config" {
187188
m.logger.Warningf("Ignoring unsupported config mode for %v: %q", config.runtime, config.mode)
188189
}
189190
config.mode = "config-file"
@@ -246,9 +247,9 @@ func (m command) validateFlags(config *config) error {
246247
// configureWrapper updates the specified container engine config to enable the NVIDIA runtime
247248
func (m command) configureWrapper(config *config) error {
248249
switch config.mode {
249-
case "oci-hook":
250+
case "oci-hook", "hook":
250251
return m.configureOCIHook(config)
251-
case "config-file":
252+
case "config-file", "config":
252253
return m.configureConfigFile(config)
253254
}
254255
return fmt.Errorf("unsupported config-mode: %v", config.mode)

0 commit comments

Comments
 (0)