mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Add nvidia-container-runtime.runtimes config option
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -65,6 +65,7 @@ func TestGetConfig(t *testing.T) {
|
||||
Experimental: false,
|
||||
DiscoverMode: "auto",
|
||||
LogLevel: "info",
|
||||
Runtimes: []string{"docker-runc", "runc"},
|
||||
},
|
||||
NVIDIACTKConfig: CTKConfig{
|
||||
Path: "nvidia-ctk",
|
||||
@@ -79,6 +80,7 @@ func TestGetConfig(t *testing.T) {
|
||||
"nvidia-container-runtime.experimental = true",
|
||||
"nvidia-container-runtime.discover-mode = \"not-legacy\"",
|
||||
"nvidia-container-runtime.log-level = \"debug\"",
|
||||
"nvidia-container-runtime.runtimes = [\"/some/runtime\",]",
|
||||
"nvidia-ctk.path = \"/foo/bar/nvidia-ctk\"",
|
||||
},
|
||||
expectedConfig: &Config{
|
||||
@@ -90,6 +92,7 @@ func TestGetConfig(t *testing.T) {
|
||||
Experimental: true,
|
||||
DiscoverMode: "not-legacy",
|
||||
LogLevel: "debug",
|
||||
Runtimes: []string{"/some/runtime"},
|
||||
},
|
||||
NVIDIACTKConfig: CTKConfig{
|
||||
Path: "/foo/bar/nvidia-ctk",
|
||||
@@ -106,6 +109,7 @@ func TestGetConfig(t *testing.T) {
|
||||
"experimental = true",
|
||||
"discover-mode = \"not-legacy\"",
|
||||
"log-level = \"debug\"",
|
||||
"runtimes = [\"/some/runtime\",]",
|
||||
"[nvidia-ctk]",
|
||||
"path = \"/foo/bar/nvidia-ctk\"",
|
||||
},
|
||||
@@ -118,6 +122,7 @@ func TestGetConfig(t *testing.T) {
|
||||
Experimental: true,
|
||||
DiscoverMode: "not-legacy",
|
||||
LogLevel: "debug",
|
||||
Runtimes: []string{"/some/runtime"},
|
||||
},
|
||||
NVIDIACTKConfig: CTKConfig{
|
||||
Path: "/foo/bar/nvidia-ctk",
|
||||
|
||||
@@ -21,6 +21,11 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
dockerRuncExecutableName = "docker-runc"
|
||||
runcExecutableName = "runc"
|
||||
)
|
||||
|
||||
// RuntimeConfig stores the config options for the NVIDIA Container Runtime
|
||||
type RuntimeConfig struct {
|
||||
DebugFilePath string
|
||||
@@ -28,6 +33,8 @@ type RuntimeConfig struct {
|
||||
DiscoverMode string
|
||||
// LogLevel defines the logging level for the application
|
||||
LogLevel string
|
||||
// Runtimes defines the candidates for the low-level runtime
|
||||
Runtimes []string
|
||||
}
|
||||
|
||||
// getRuntimeConfigFrom reads the nvidia container runtime config from the specified toml Tree.
|
||||
@@ -43,6 +50,15 @@ func getRuntimeConfigFrom(toml *toml.Tree) *RuntimeConfig {
|
||||
cfg.DiscoverMode = toml.GetDefault("nvidia-container-runtime.discover-mode", cfg.DiscoverMode).(string)
|
||||
cfg.LogLevel = toml.GetDefault("nvidia-container-runtime.log-level", cfg.LogLevel).(string)
|
||||
|
||||
configRuntimes := toml.Get("nvidia-container-runtime.runtimes")
|
||||
if configRuntimes != nil {
|
||||
var runtimes []string
|
||||
for _, r := range configRuntimes.([]interface{}) {
|
||||
runtimes = append(runtimes, r.(string))
|
||||
}
|
||||
cfg.Runtimes = runtimes
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
@@ -53,6 +69,10 @@ func GetDefaultRuntimeConfig() *RuntimeConfig {
|
||||
Experimental: false,
|
||||
DiscoverMode: "auto",
|
||||
LogLevel: logrus.InfoLevel.String(),
|
||||
Runtimes: []string{
|
||||
dockerRuncExecutableName,
|
||||
runcExecutableName,
|
||||
},
|
||||
}
|
||||
|
||||
return &c
|
||||
|
||||
Reference in New Issue
Block a user