From 0c7eb93d622b6a06a91b6d5d467075c70cfe8f3e Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Thu, 24 Mar 2022 13:45:03 +0200 Subject: [PATCH] Add experimental option to NVIDIA Container Runtime config This change adds an experimental option to the NVIDIA Container Runtime config. To simplify the extension of this experimental mode in future an error is raised if this is enabled. Signed-off-by: Evan Lezar --- cmd/nvidia-container-runtime/main.go | 6 ++++-- cmd/nvidia-container-runtime/runtime_factory.go | 6 +++++- packaging/debian/changelog | 2 +- packaging/rpm/SPECS/nvidia-container-toolkit.spec | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/nvidia-container-runtime/main.go b/cmd/nvidia-container-runtime/main.go index 69f822bf..6d103983 100644 --- a/cmd/nvidia-container-runtime/main.go +++ b/cmd/nvidia-container-runtime/main.go @@ -47,16 +47,17 @@ func run(argv []string) (rerr error) { logger.CloseFile() }() - r, err := newNVIDIAContainerRuntime(logger.Logger, cfg, argv) + runtime, err := newNVIDIAContainerRuntime(logger.Logger, cfg, argv) if err != nil { return fmt.Errorf("error creating runtime: %v", err) } - return r.Exec(argv) + return runtime.Exec(argv) } type config struct { debugFilePath string + Experimental bool } // getConfig sets up the config struct. Values are read from a toml file @@ -81,6 +82,7 @@ func getConfig() (*config, error) { } cfg.debugFilePath = toml.GetDefault("nvidia-container-runtime.debug", "/dev/null").(string) + cfg.Experimental = toml.GetDefault("nvidia-container-runtime.experimental", false).(bool) return cfg, nil } diff --git a/cmd/nvidia-container-runtime/runtime_factory.go b/cmd/nvidia-container-runtime/runtime_factory.go index 8b547935..3b6dbef7 100644 --- a/cmd/nvidia-container-runtime/runtime_factory.go +++ b/cmd/nvidia-container-runtime/runtime_factory.go @@ -43,7 +43,11 @@ func newNVIDIAContainerRuntime(logger *logrus.Logger, cfg *config, argv []string return nil, fmt.Errorf("error constructing low-level runtime: %v", err) } - specModifier := modifier.NewStableRuntimeModifier(logger) + var specModifier oci.SpecModifier + if cfg.Experimental { + return nil, fmt.Errorf("experimental mode is not supported") + } + specModifier = modifier.NewStableRuntimeModifier(logger) // Create the wrapping runtime with the specified modifier r := runtime.NewModifyingRuntimeWrapper( diff --git a/packaging/debian/changelog b/packaging/debian/changelog index 5b0ec14d..67ad3690 100644 --- a/packaging/debian/changelog +++ b/packaging/debian/changelog @@ -1,6 +1,6 @@ nvidia-container-toolkit (1.10.0~rc.1-1) experimental; urgency=medium - * Dummy entry + * Add experimental option to NVIDIA Container Runtime -- NVIDIA CORPORATION Thu, 24 Mar 2022 13:22:24 +0200 diff --git a/packaging/rpm/SPECS/nvidia-container-toolkit.spec b/packaging/rpm/SPECS/nvidia-container-toolkit.spec index 72533802..678c3012 100644 --- a/packaging/rpm/SPECS/nvidia-container-toolkit.spec +++ b/packaging/rpm/SPECS/nvidia-container-toolkit.spec @@ -65,7 +65,7 @@ rm -f %{_bindir}/nvidia-container-runtime-hook %changelog * Thu Mar 24 2022 NVIDIA CORPORATION 1.10.0-0.1.rc.1 -- Dummy entry +- Add experimental option to NVIDIA Container Runtime * Fri Mar 18 2022 NVIDIA CORPORATION 1.9.0-1 - [libnvidia-container] Add additional check for Tegra in /sys/.../family file in CLI