From 7c807c2c221dfdc34f15542fef5423203c741053 Mon Sep 17 00:00:00 2001 From: Evan Lezar <7723350-elezar@users.noreply.gitlab.com> Date: Tue, 6 Jun 2023 18:29:59 +0000 Subject: [PATCH] Merge branch 'CNT-4302/cdi-only' into 'main' Skip additional modifications in CDI mode See merge request nvidia/container-toolkit/container-toolkit!413 --- CHANGELOG.md | 1 + internal/runtime/runtime_factory.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5186292b..89c3d03a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Generate CDI specification files with `644` permissions to allow rootless applications (e.g. podman). * Fix bug causing incorrect nvidia-smi symlink to be created on WSL2 systems with multiple driver roots. * Fix bug when using driver versions that do not include a patch component in their version number. +* Skip additional modifications in CDI mode. * [toolkit-container] Allow same envars for all runtime configs diff --git a/internal/runtime/runtime_factory.go b/internal/runtime/runtime_factory.go index 0547d3ad..f453f456 100644 --- a/internal/runtime/runtime_factory.go +++ b/internal/runtime/runtime_factory.go @@ -61,10 +61,15 @@ func newNVIDIAContainerRuntime(logger *logrus.Logger, cfg *config.Config, argv [ // newSpecModifier is a factory method that creates constructs an OCI spec modifer based on the provided config. func newSpecModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec, argv []string) (oci.SpecModifier, error) { - modeModifier, err := newModeModifier(logger, cfg, ociSpec, argv) + mode := info.ResolveAutoMode(logger, cfg.NVIDIAContainerRuntimeConfig.Mode) + modeModifier, err := newModeModifier(logger, mode, cfg, ociSpec, argv) if err != nil { return nil, err } + // For CDI mode we make no additional modifications. + if mode == "cdi" { + return modeModifier, nil + } graphicsModifier, err := modifier.NewGraphicsModifier(logger, cfg, ociSpec) if err != nil { @@ -96,8 +101,8 @@ func newSpecModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec return modifiers, nil } -func newModeModifier(logger *logrus.Logger, cfg *config.Config, ociSpec oci.Spec, argv []string) (oci.SpecModifier, error) { - switch info.ResolveAutoMode(logger, cfg.NVIDIAContainerRuntimeConfig.Mode) { +func newModeModifier(logger *logrus.Logger, mode string, cfg *config.Config, ociSpec oci.Spec, argv []string) (oci.SpecModifier, error) { + switch mode { case "legacy": return modifier.NewStableRuntimeModifier(logger, cfg.NVIDIAContainerRuntimeHookConfig.Path), nil case "csv":