mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Set default spec dirs at config level
This change sets the default CDI spec dirs at a config level instead of when a CDI runtime modifier is constructed. This makes this setting consistent with other options such as the nvidia-ctk path. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
2c5761d32e
commit
e2f8d2a15f
@ -151,6 +151,7 @@ func getDefault() (*Config, error) {
|
||||
CDI: cdiModeConfig{
|
||||
DefaultKind: "nvidia.com/gpu",
|
||||
AnnotationPrefixes: []string{cdi.AnnotationPrefix},
|
||||
SpecDirs: cdi.DefaultSpecDirs,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -77,6 +77,7 @@ func TestGetConfig(t *testing.T) {
|
||||
CDI: cdiModeConfig{
|
||||
DefaultKind: "nvidia.com/gpu",
|
||||
AnnotationPrefixes: []string{"cdi.k8s.io/"},
|
||||
SpecDirs: []string{"/etc/cdi", "/var/run/cdi"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -102,6 +103,7 @@ func TestGetConfig(t *testing.T) {
|
||||
"nvidia-container-runtime.mode = \"not-auto\"",
|
||||
"nvidia-container-runtime.modes.cdi.default-kind = \"example.vendor.com/device\"",
|
||||
"nvidia-container-runtime.modes.cdi.annotation-prefixes = [\"cdi.k8s.io/\", \"example.vendor.com/\",]",
|
||||
"nvidia-container-runtime.modes.cdi.spec-dirs = [\"/except/etc/cdi\", \"/not/var/run/cdi\",]",
|
||||
"nvidia-container-runtime.modes.csv.mount-spec-path = \"/not/etc/nvidia-container-runtime/host-files-for-container.d\"",
|
||||
"nvidia-container-runtime-hook.path = \"/foo/bar/nvidia-container-runtime-hook\"",
|
||||
"nvidia-ctk.path = \"/foo/bar/nvidia-ctk\"",
|
||||
@ -128,6 +130,10 @@ func TestGetConfig(t *testing.T) {
|
||||
"cdi.k8s.io/",
|
||||
"example.vendor.com/",
|
||||
},
|
||||
SpecDirs: []string{
|
||||
"/except/etc/cdi",
|
||||
"/not/var/run/cdi",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -156,6 +162,7 @@ func TestGetConfig(t *testing.T) {
|
||||
"[nvidia-container-runtime.modes.cdi]",
|
||||
"default-kind = \"example.vendor.com/device\"",
|
||||
"annotation-prefixes = [\"cdi.k8s.io/\", \"example.vendor.com/\",]",
|
||||
"spec-dirs = [\"/except/etc/cdi\", \"/not/var/run/cdi\",]",
|
||||
"[nvidia-container-runtime.modes.csv]",
|
||||
"mount-spec-path = \"/not/etc/nvidia-container-runtime/host-files-for-container.d\"",
|
||||
"[nvidia-container-runtime-hook]",
|
||||
@ -185,6 +192,10 @@ func TestGetConfig(t *testing.T) {
|
||||
"cdi.k8s.io/",
|
||||
"example.vendor.com/",
|
||||
},
|
||||
SpecDirs: []string{
|
||||
"/except/etc/cdi",
|
||||
"/not/var/run/cdi",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -48,14 +48,9 @@ func NewCDIModifier(logger logger.Interface, cfg *config.Config, ociSpec oci.Spe
|
||||
}
|
||||
logger.Debugf("Creating CDI modifier for devices: %v", devices)
|
||||
|
||||
specDirs := cdi.DefaultSpecDirs
|
||||
if len(cfg.NVIDIAContainerRuntimeConfig.Modes.CDI.SpecDirs) > 0 {
|
||||
specDirs = cfg.NVIDIAContainerRuntimeConfig.Modes.CDI.SpecDirs
|
||||
}
|
||||
|
||||
m := cdiModifier{
|
||||
logger: logger,
|
||||
specDirs: specDirs,
|
||||
specDirs: cfg.NVIDIAContainerRuntimeConfig.Modes.CDI.SpecDirs,
|
||||
devices: devices,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user