Skip to content

[Bug]: Unreachable code prevents lib-modules volume mount when using precompiled drivers. #2776

Description

@piyushtiwari11

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.

Metadata

Metadata

Assignees

Labels

bugIssue/PR to expose/discuss/fix a bugneeds-triageissue or PR has not been assigned a priority-px label

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions