Handle case were runtime name is set to predefined name

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-03-07 20:59:22 +02:00
parent 62d88e7c95
commit cc7a6f166b

View File

@ -84,8 +84,13 @@ func (r *Runtimes) add(runtime Runtime) {
// nvidiaRuntime creates a runtime that corresponds to the nvidia runtime. // nvidiaRuntime creates a runtime that corresponds to the nvidia runtime.
// If the nvidiaRuntimeName is specified, this name us used unless this is exactly equal to nvidia-experimental. // If the nvidiaRuntimeName is specified, this name us used unless this is exactly equal to nvidia-experimental.
func (c config) nvidiaRuntime() Runtime { func (c config) nvidiaRuntime() Runtime {
predefinedRuntimes := map[string]struct{}{
"nvidia-experimental": {},
"nvidia-cdi": {},
"nvidia-legacy": {},
}
name := c.nvidiaRuntimeName name := c.nvidiaRuntimeName
if name == experimentalRuntimeName { if _, isPredefinedRuntime := predefinedRuntimes[name]; isPredefinedRuntime {
name = defaultRuntimeName name = defaultRuntimeName
} }
return c.newRuntime(name, "nvidia-container-runtime") return c.newRuntime(name, "nvidia-container-runtime")