Skip to content

Commit b578788

Browse files
Prevent operand pods from starting before nvidia driver is loaded
When an operand pod (mig-manager, device-plugin, GFD, etc.) is created while the nvidia driver module is not loaded, the nvidia container runtime wrapper falls back to plain runc/crun. This means no NVIDIA libraries are injected into the container — the container is permanently broken for its lifetime. The init containers in these pods gate on the toolkit-ready sentinel file, but this file can be validly present from a running operator-validator even while the driver is temporarily unloaded (e.g., during a driver container restart). The sentinel file system validates that components were installed correctly but does not validate that the nvidia kernel module is currently loaded — which is the actual condition required for the container runtime to inject NVIDIA libraries. Add a /proc/modules check for the nvidia kernel module alongside the existing toolkit-ready file check in all operand init containers. This ensures the main container is not created until the nvidia module is loaded, guaranteeing the runtime wrapper invokes the real nvidia-container-runtime (which injects libraries) instead of falling back to runc. Additionally, add preStop lifecycle hooks to the toolkit and driver containers to clean up sentinel files (toolkit-ready, driver-ready) on graceful termination. This prevents downstream init containers from passing on stale files when pods are properly terminated during upgrades or drains. Co-authored-by: Shiva Kumar <shivaku@nvidia.com> Signed-off-by: Rajath Agasthya <ragasthya@nvidia.com>
1 parent 652724d commit b578788

8 files changed

Lines changed: 11 additions & 7 deletions

File tree

assets/gpu-feature-discovery/0500_daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spec:
2929
- name: toolkit-validation
3030
image: "FILLED BY THE OPERATOR"
3131
command: ['sh', '-c']
32-
args: ["until [ -f /run/nvidia/validations/toolkit-ready ]; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
32+
args: ["until [ -f /run/nvidia/validations/toolkit-ready ] && grep -q '^nvidia ' /proc/modules; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
3333
securityContext:
3434
privileged: true
3535
volumeMounts:

assets/state-container-toolkit/0500_daemonset.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ spec:
7777
fieldPath: metadata.namespace
7878
imagePullPolicy: IfNotPresent
7979
name: nvidia-container-toolkit-ctr
80+
lifecycle:
81+
preStop:
82+
exec:
83+
command: ["/bin/sh", "-c", "rm -f /run/nvidia/validations/toolkit-ready"]
8084
securityContext:
8185
privileged: true
8286
seLinuxOptions:

assets/state-dcgm-exporter/0800_daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
- name: toolkit-validation
2929
image: "FILLED BY THE OPERATOR"
3030
command: ['sh', '-c']
31-
args: ["until [ -f /run/nvidia/validations/toolkit-ready ]; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
31+
args: ["until [ -f /run/nvidia/validations/toolkit-ready ] && grep -q '^nvidia ' /proc/modules; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
3232
securityContext:
3333
privileged: true
3434
volumeMounts:

assets/state-dcgm/0400_dcgm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
- name: toolkit-validation
2929
image: "FILLED BY THE OPERATOR"
3030
command: ['sh', '-c']
31-
args: ["until [ -f /run/nvidia/validations/toolkit-ready ]; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
31+
args: ["until [ -f /run/nvidia/validations/toolkit-ready ] && grep -q '^nvidia ' /proc/modules; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
3232
securityContext:
3333
privileged: true
3434
volumeMounts:

assets/state-device-plugin/0500_daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
- image: "FILLED BY THE OPERATOR"
2929
name: toolkit-validation
3030
command: ['sh', '-c']
31-
args: ["until [ -f /run/nvidia/validations/toolkit-ready ]; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
31+
args: ["until [ -f /run/nvidia/validations/toolkit-ready ] && grep -q '^nvidia ' /proc/modules; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
3232
securityContext:
3333
privileged: true
3434
volumeMounts:

assets/state-driver/0500_daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ spec:
150150
lifecycle:
151151
preStop:
152152
exec:
153-
command: ["/bin/sh", "-c", "rm -f /run/nvidia/validations/.driver-ctr-ready"]
153+
command: ["/bin/sh", "-c", "rm -f /run/nvidia/validations/.driver-ctr-ready /run/nvidia/validations/driver-ready"]
154154
- image: "FILLED BY THE OPERATOR"
155155
imagePullPolicy: IfNotPresent
156156
name: nvidia-peermem-ctr

assets/state-mig-manager/0600_daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
- name: toolkit-validation
2929
image: "FILLED BY THE OPERATOR"
3030
command: ['sh', '-c']
31-
args: ["until [ -f /run/nvidia/validations/toolkit-ready ]; do echo waiting for nvidia container toolkit to be setup; sleep 5; done"]
31+
args: ["until [ -f /run/nvidia/validations/toolkit-ready ] && grep -q '^nvidia ' /proc/modules; do echo waiting for nvidia container toolkit to be setup; sleep 5; done"]
3232
securityContext:
3333
privileged: true
3434
volumeMounts:

assets/state-mps-control-daemon/0400_daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
- image: "FILLED BY THE OPERATOR"
3131
name: toolkit-validation
3232
command: ['sh', '-c']
33-
args: ["until [ -f /run/nvidia/validations/toolkit-ready ]; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
33+
args: ["until [ -f /run/nvidia/validations/toolkit-ready ] && grep -q '^nvidia ' /proc/modules; do echo waiting for nvidia container stack to be setup; sleep 5; done"]
3434
securityContext:
3535
privileged: true
3636
volumeMounts:

0 commit comments

Comments
 (0)