From 70920d7a04817199fa9f9703d9c24606ee688662 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Thu, 23 Mar 2023 14:57:18 +0200 Subject: [PATCH] Add support for containerd to the runtime configure CLI Signed-off-by: Evan Lezar --- CHANGELOG.md | 2 ++ cmd/nvidia-ctk/runtime/configure/configure.go | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 472a74e1..f5b7dbff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## v1.14.0-rc.1 +* Add support for updating containerd configs to the `nvidia-ctk runtime configure` command. + ## v1.13.1 * Update `update-ldcache` hook to only update ldcache if it exists. diff --git a/cmd/nvidia-ctk/runtime/configure/configure.go b/cmd/nvidia-ctk/runtime/configure/configure.go index a25d4b2d..bcc41953 100644 --- a/cmd/nvidia-ctk/runtime/configure/configure.go +++ b/cmd/nvidia-ctk/runtime/configure/configure.go @@ -21,6 +21,7 @@ import ( "path/filepath" "github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine" + "github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/containerd" "github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/crio" "github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/docker" "github.com/sirupsen/logrus" @@ -36,8 +37,9 @@ const ( defaultNVIDIARuntimeExecutable = "nvidia-container-runtime" defailtNVIDIARuntimeExpecutablePath = "/usr/bin/nvidia-container-runtime" - defaultCrioConfigFilePath = "/etc/crio/crio.conf" - defaultDockerConfigFilePath = "/etc/docker/daemon.json" + defaultContainerdConfigFilePath = "/etc/containerd/config.toml" + defaultCrioConfigFilePath = "/etc/crio/crio.conf" + defaultDockerConfigFilePath = "/etc/docker/daemon.json" ) type command struct { @@ -90,7 +92,7 @@ func (m command) build() *cli.Command { }, &cli.StringFlag{ Name: "runtime", - Usage: "the target runtime engine; one of [crio, docker]", + Usage: "the target runtime engine; one of [containerd, crio, docker]", Value: defaultRuntime, Destination: &config.runtime, }, @@ -125,14 +127,14 @@ func (m command) build() *cli.Command { func validateFlags(c *cli.Context, config *config) error { switch config.runtime { - case "crio", "docker": + case "containerd", "crio", "docker": break default: return fmt.Errorf("unrecognized runtime '%v'", config.runtime) } switch config.runtime { - case "crio": + case "containerd", "crio": if config.nvidiaRuntime.path == defaultNVIDIARuntimeExecutable { config.nvidiaRuntime.path = defailtNVIDIARuntimeExpecutablePath } @@ -151,6 +153,10 @@ func (m command) configureWrapper(c *cli.Context, config *config) error { var cfg engine.Interface var err error switch config.runtime { + case "containerd": + cfg, err = containerd.New( + containerd.WithPath(configFilePath), + ) case "crio": cfg, err = crio.New( crio.WithPath(configFilePath), @@ -197,6 +203,8 @@ func (c *config) resolveConfigFilePath() string { return c.configFilePath } switch c.runtime { + case "containerd": + return defaultContainerdConfigFilePath case "crio": return defaultCrioConfigFilePath case "docker":