Skip to content

Commit

Permalink
configure crun as the low-level runtime to prioritise when using CRI-O
Browse files Browse the repository at this point in the history
Signed-off-by: Tariq Ibrahim <[email protected]>
  • Loading branch information
tariq1890 committed Sep 11, 2024
1 parent 4a7f9dc commit cac5e00
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion controllers/object_controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit cac5e00

Please sign in to comment.