Skip to content
Merged
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
16 changes: 15 additions & 1 deletion cmd/nvidia-ctk-installer/container/runtime/crio/crio.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk-installer/container"
"github.com/NVIDIA/nvidia-container-toolkit/internal/config"
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine"
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine/crio"
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/ocihook"
Expand All @@ -35,7 +36,10 @@ import (
const (
Name = "crio"

defaultConfigMode = "hook"
defaultConfigMode = configModeConfig

configModeConfig = "config"
configModeHook = "hook"

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

func (opts *Options) Validate(logger logger.Interface, _ *cli.Command) error {
if opts.configMode != configModeConfig && opts.configMode != configModeHook {
return fmt.Errorf("invalid cri-o config mode: %q", opts.configMode)
}
if opts.configMode == configModeHook {
logger.Warningf("The %q config for cri-o is deprecated", opts.configMode)
}
return nil
}

// Setup installs the prestart hook required to launch GPU-enabled containers
func Setup(c *cli.Command, o *container.Options, co *Options) error {
log.Infof("Starting 'setup' for %v", c.Name)
Expand Down
3 changes: 3 additions & 0 deletions cmd/nvidia-ctk-installer/container/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func (opts *Options) Validate(logger logger.Interface, c *cli.Command, runtime s
}
case containerd.Name:
case crio.Name:
if err := opts.crioOptions.Validate(logger, c); err != nil {
return fmt.Errorf("invalid cri-o config: %w", err)
}
}

// Apply the runtime-specific config changes.
Expand Down
9 changes: 5 additions & 4 deletions cmd/nvidia-ctk/runtime/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,14 @@ func (m command) build() *cli.Command {
}

func (m command) validateFlags(config *config) error {
if config.mode == "oci-hook" {
if config.mode == "oci-hook" || config.mode == "hook" {
m.logger.Warningf("The %q config-mode is deprecated", config.mode)
if !filepath.IsAbs(config.nvidiaRuntime.hookPath) {
return fmt.Errorf("the NVIDIA runtime hook path %q is not an absolute path", config.nvidiaRuntime.hookPath)
}
return nil
}
if config.mode != "" && config.mode != "config-file" {
if config.mode != "" && config.mode != "config-file" && config.mode != "config" {
m.logger.Warningf("Ignoring unsupported config mode for %v: %q", config.runtime, config.mode)
}
config.mode = "config-file"
Expand Down Expand Up @@ -246,9 +247,9 @@ func (m command) validateFlags(config *config) error {
// configureWrapper updates the specified container engine config to enable the NVIDIA runtime
func (m command) configureWrapper(config *config) error {
switch config.mode {
case "oci-hook":
case "oci-hook", "hook":
return m.configureOCIHook(config)
case "config-file":
case "config-file", "config":
return m.configureConfigFile(config)
}
return fmt.Errorf("unsupported config-mode: %v", config.mode)
Expand Down