From 538d4020df9dbdda3f8468d62873d8db10b72940 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 6 Sep 2023 17:51:15 +0200 Subject: [PATCH 1/3] Bump version to v1.14.1 Signed-off-by: Evan Lezar --- CHANGELOG.md | 2 ++ versions.mk | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d03814..8dd2a01a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # NVIDIA Container Toolkit Changelog +## v1.14.1 + ## v1.14.0 * Promote v1.14.0-rc.3 to v1.14.0 diff --git a/versions.mk b/versions.mk index e974a5b7..52d43c86 100644 --- a/versions.mk +++ b/versions.mk @@ -13,7 +13,7 @@ # limitations under the License. LIB_NAME := nvidia-container-toolkit -LIB_VERSION := 1.14.0 +LIB_VERSION := 1.14.1 LIB_TAG := # The package version is the combination of the library version and tag. From d74f7fef4e5f687a983e1e6eed4794c4ce661a9b Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Thu, 7 Sep 2023 11:54:24 +0200 Subject: [PATCH 2/3] Update libnvidia-container to fix rpm builds Signed-off-by: Evan Lezar --- CHANGELOG.md | 1 + third_party/libnvidia-container | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dd2a01a..02075e6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # NVIDIA Container Toolkit Changelog ## v1.14.1 +* Use libelf.so on RPM-based systems due to removed mageia repositories hosting pmake and bmake. ## v1.14.0 * Promote v1.14.0-rc.3 to v1.14.0 diff --git a/third_party/libnvidia-container b/third_party/libnvidia-container index 6a24508d..86b6e511 160000 --- a/third_party/libnvidia-container +++ b/third_party/libnvidia-container @@ -1 +1 @@ -Subproject commit 6a24508dff6cb36841114ff4c1287cd29ded72af +Subproject commit 86b6e51145f2a53257658682b7ae8e24f39e6649 From 4ec9bd751e9e75e1698bc407cb98678ddc54f916 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 6 Sep 2023 17:24:36 +0200 Subject: [PATCH 3/3] Add required option to new toml config This change adds a "required" option to the new toml config that controls whether a default config is returned or not. This is useful from the NVIDIA Container Runtime Hook, where /run/driver/nvidia/etc/nvidia-container-runtime/config.toml is checked before the standard path. This fixes a bug where the default config was always applied when this config was not used. See https://github.com/NVIDIA/nvidia-container-toolkit/issues/106 Signed-off-by: Evan Lezar --- CHANGELOG.md | 1 + .../hook_config.go | 1 + internal/config/toml.go | 21 ++++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02075e6e..d98c71af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v1.14.1 * Use libelf.so on RPM-based systems due to removed mageia repositories hosting pmake and bmake. +* Fixed bug where contents of `/etc/nvidia-container-runtime/config.toml` is ignored by the NVIDIA Container Runtime Hook. ## v1.14.0 * Promote v1.14.0-rc.3 to v1.14.0 diff --git a/cmd/nvidia-container-runtime-hook/hook_config.go b/cmd/nvidia-container-runtime-hook/hook_config.go index 4188765f..3bd0828f 100644 --- a/cmd/nvidia-container-runtime-hook/hook_config.go +++ b/cmd/nvidia-container-runtime-hook/hook_config.go @@ -45,6 +45,7 @@ func loadConfig() (*config.Config, error) { for _, p := range configPaths { cfg, err := config.New( config.WithConfigFile(p), + config.WithRequired(true), ) if err == nil { return cfg.Config() diff --git a/internal/config/toml.go b/internal/config/toml.go index 8e39702a..8c931675 100644 --- a/internal/config/toml.go +++ b/internal/config/toml.go @@ -31,6 +31,7 @@ type Toml toml.Tree type options struct { configFile string + required bool } // Option is a functional option for loading TOML config files. @@ -43,6 +44,14 @@ func WithConfigFile(configFile string) Option { } } +// WithRequired sets the required option. +// If this is set to true, a failure to open the specified file is treated as an error +func WithRequired(required bool) Option { + return func(o *options) { + o.required = required + } +} + // New creates a new toml tree based on the provided options func New(opts ...Option) (*Toml, error) { o := &options{} @@ -50,19 +59,25 @@ func New(opts ...Option) (*Toml, error) { opt(o) } - return loadConfigToml(o.configFile) + return o.loadConfigToml() } -func loadConfigToml(filename string) (*Toml, error) { +func (o options) loadConfigToml() (*Toml, error) { + filename := o.configFile if filename == "" { return defaultToml() } + _, err := os.Stat(filename) + if os.IsNotExist(err) && o.required { + return nil, os.ErrNotExist + } + tomlFile, err := os.Open(filename) if os.IsNotExist(err) { return defaultToml() } else if err != nil { - return nil, fmt.Errorf("failed to load specified config file: %v", err) + return nil, fmt.Errorf("failed to load specified config file: %w", err) } defer tomlFile.Close()