diff --git a/controllers/object_controls.go b/controllers/object_controls.go index 748347981..e24f70f57 100644 --- a/controllers/object_controls.go +++ b/controllers/object_controls.go @@ -143,6 +143,8 @@ const ( VgpuDMDefaultConfigName = "default" // NvidiaCtrRuntimeModeEnvName is the name of the toolkit container env for configuring the NVIDIA Container Runtime mode NvidiaCtrRuntimeModeEnvName = "NVIDIA_CONTAINER_RUNTIME_MODE" + // NvidiaCtrRuntimeRuntimesEnvName is the name of the toolkit container env for configuring the NVIDIA Container Runtime mode + NvidiaCtrRuntimeRuntimesEnvName = "NVIDIA_CONTAINER_RUNTIME_RUNTIMES" // NvidiaCtrRuntimeCDIPrefixesEnvName is the name of toolkit container env for configuring the CDI annotation prefixes NvidiaCtrRuntimeCDIPrefixesEnvName = "NVIDIA_CONTAINER_RUNTIME_MODES_CDI_ANNOTATION_PREFIXES" // CDIEnabledEnvName is the name of the envvar used to enable CDI in the operands @@ -1208,6 +1210,8 @@ func TransformToolkit(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n } } + runtime := n.runtime.String() + // update env required for CDI support if config.CDI.IsEnabled() { setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), CDIEnabledEnvName, "true") @@ -1218,6 +1222,13 @@ func TransformToolkit(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n } } + // As crun is the default low-level-runtime in CRI-O, we configure the toolkit to favour crun when running the + // toolkit setup and bootstrapping the nvidia-container-runtime wrapper binary. + if runtime == gpuv1.CRIO.String() { + setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), NvidiaCtrRuntimeRuntimesEnvName, + "/usr/libexec/crio/crun,/usr/libexec/crio/runc,crun,runc") + } + // set install directory for the toolkit if config.Toolkit.InstallDir != "" && config.Toolkit.InstallDir != DefaultToolkitInstallDir { setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), ToolkitInstallDirEnvName, config.Toolkit.InstallDir) @@ -1238,7 +1249,6 @@ func TransformToolkit(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n } // configure runtime - runtime := n.runtime.String() err = transformForRuntime(obj, config, runtime, "nvidia-container-toolkit-ctr") if err != nil { return fmt.Errorf("error transforming toolkit daemonset : %w", err)