Description
When deploying an NVIDIA driver Custom Resource with usePrecompiledDrivers: true, the lib-modules volume is not being mounted inside the driver pod.
This happens because of conflicting conditional checks in internal/state/driver_volumes.go within the getDriverAdditionalConfigs function, which creates an unreachable execution path.
Code Reference
- Repository: NVIDIA/gpu-operator
- File:
internal/state/driver_volumes.go (commit de69cf78225fa0b3f7bea871e91783630fa104f5)
- Function:
getDriverAdditionalConfigs (line 140)
Details
At line 145, the code checks if precompiled drivers are disabled before entering the block:
if !cr.Spec.UsePrecompiledDrivers() {
// ...
However, inside this exact same block at line 226, there is a contradictory condition checking if precompiled drivers are enabled:
if cr.Spec.UsePrecompiledDrivers() {
// ...
Since the outer if statement enforces UsePrecompiledDrivers() as false, the inner condition at line 226 evaluates to false in every scenario. This results in dead code, meaning the volume mount below is never executed or appended to the pod:
libModulesVolMount := corev1.VolumeMount{
Name: "lib-modules",
MountPath: "/run/host/lib/modules",
ReadOnly: true,
}
Environment
- GPU Operator Version: v24.9.2
Expected Behavior
When usePrecompiledDrivers: true is set, the lib-modules volume mount should be successfully evaluated and mounted to the pod. The logic should be refactored so that the lib-modules mount configuration is not trapped inside a contradictory !cr.Spec.UsePrecompiledDrivers() block.
Actual Behavior
The logic silently skips the volume mount configuration, resulting in a pod deployed without the necessary /run/host/lib/modules mount.
Description
When deploying an NVIDIA driver Custom Resource with
usePrecompiledDrivers: true, thelib-modulesvolume is not being mounted inside the driver pod.This happens because of conflicting conditional checks in
internal/state/driver_volumes.gowithin thegetDriverAdditionalConfigsfunction, which creates an unreachable execution path.Code Reference
internal/state/driver_volumes.go(commitde69cf78225fa0b3f7bea871e91783630fa104f5)getDriverAdditionalConfigs(line 140)Details
At line 145, the code checks if precompiled drivers are disabled before entering the block:
However, inside this exact same block at line 226, there is a contradictory condition checking if precompiled drivers are enabled:
Since the outer
ifstatement enforcesUsePrecompiledDrivers()asfalse, the inner condition at line 226 evaluates tofalsein every scenario. This results in dead code, meaning the volume mount below is never executed or appended to the pod:Environment
Expected Behavior
When
usePrecompiledDrivers: trueis set, thelib-modulesvolume mount should be successfully evaluated and mounted to the pod. The logic should be refactored so that thelib-modulesmount configuration is not trapped inside a contradictory!cr.Spec.UsePrecompiledDrivers()block.Actual Behavior
The logic silently skips the volume mount configuration, resulting in a pod deployed without the necessary
/run/host/lib/modulesmount.