You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add mock-NVML XID and recovery-action support for GPU health e2e - #1509
CPU-only mock-NVML CI cannot exercise GPU health checking. The pinned mock emits at most one failure-injector XID, always with GPU instance and compute instance 0, and it does not implement NVML_FI_DEV_GET_GPU_RECOVERY_ACTION. This driver ignores instance 0 for a full GPU and classifies an XID from the recovery action, so those tests never observe a taint.
The mock setup now patches the pinned library at build time. Tests write /driver-root/health-control.json in the GPU plugin container. Each event sets the GPU, XID, GPU instance, and compute instance. Omitted instance IDs mean the full GPU (0xFFFFFFFF). recoveryActions accepts GPU_RECOVERY_ACTION_NONE, GPU_RESET, and the other NVML recovery actions, and a later rewrite of the file moves a GPU back to NONE for a future taint-removal test. tests/bats/test_gpu_health.bats runs in the mock-NVML suite and checks:
A MIG-scoped XID (GI=3, CI=1) is not applied to the full GPU.
Recovery action NONE publishes gpu.nvidia.com/xid with effect None.
GPU_RESET publishes effect NoSchedule, and that taint remains after the mock reports NONE again.
--additional-xids-to-ignore keeps a GPU_RESET XID informational.
On Kubernetes 1.35 and earlier, the Kind cluster enables DRADeviceTaints so those ResourceSlice taints are stored.
The health-control sources live in this repo and are copied into the pinned k8s-test-infra mock checkout during setup-mock-gpu.sh. nvmlDeviceGetFieldValues still returns the historical not-supported stub unless the caller asks for field 230 (NVML_FI_DEV_GET_GPU_RECOVERY_ACTION).
This pull-request has been approved by: vishalanarase Once this PR has been reviewed and has the lgtm label, please assign dims for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Details
Needs approval from an approver in each of these files:
The reason will be displayed to describe this comment to others. Learn more.
This edits our local copy of k8s-test-infra by exact string match, so it will break the next time we bump the pin. Upstream HEAD has already replaced data.gpuInstanceId = 0 with C.uint(nvmlNoMIGInstanceID), so this die() would fail the mock-NVML job. Could you skip this step when upstream already sets the full-GPU value? Longer term, could you open an issue or PR in NVIDIA/k8s-test-infra for GI/CI on XID events and the recovery-action field (230)? Then this patch can go away and this PR only needs to bump the pin and add the tests.
The reason will be displayed to describe this comment to others. Learn more.
The pinned mock still rewrites gpuInstanceId = 0 to the full-GPU sentinel. If the file already uses 0xFFFFFFFF or nvmlNoMIGInstanceID, that step is skipped instead of failing the job. The longer-term request is in NVIDIA/k8s-test-infra#1384, with the suggested control-file and field-230 change. Once that lands, this patch can go away and the driver only needs a pin bump.
The reason will be displayed to describe this comment to others. Learn more.
With the pin at 18befbf, which main already uses, most of this script never does anything. nvml_types.h already defines nvmlFieldValue_t. nvmlDeviceGetFieldValues is already exported from bridge/fieldvalues.go, so the stub removal and the overlay/fieldvalues.go copy get skipped. The PCI bus ID lookup already goes through canonicalPCIBusID. Could you drop patch_header, remove_field_value_stub, patch_pci_bus_id_lookup, the overlay branch in copy_sources, overlay/fieldvalues.go, and their constants, and only target the pinned version?
The reason will be displayed to describe this comment to others. Learn more.
Dropped patch_header, remove_field_value_stub, patch_pci_bus_id_lookup, the field-values overlay copy, and overlay/fieldvalues.go. The script now only targets the pinned checkout: it copies the health-control sources, claims those events before pendingXidClaim(), and hooks recovery-action field 230 into GetFieldValue.
The reason will be displayed to describe this comment to others. Learn more.
This test file leaves state behind that affects subsequent files. /driver-root is a hostPath, so the control file survives plugin restarts, and the last test leaves the plugin installed with ADDITIONAL_XIDS_TO_IGNORE=79.
When the next file upgrades the chart, the plugin restarts with an empty delivered-ID map and processes ignored-79 again. With the default ignore list, it treats XID 79 as fatal and adds a NoSchedule taint to gpu-0, affecting every later test. CI currently passes because the following test_cd_* files don’t need that GPU.
Please add a teardown_file that clears the control file before reinstalling the plugin with the default args. This ensures the plugin restarts cleanly and removes the taints introduced by this file.
The reason will be displayed to describe this comment to others. Learn more.
Added teardown_file. It clears /driver-root/health-control.json, then reinstalls the plugin with the suite's default args (logVerbosity=6, and compute domains left disabled when this run disabled them). The next file's upgrade no longer replays ignored-79 as a fatal XID on gpu-0.
Limit the local mock patch to the pinned checkout, and skip the GI/CI rewrite when upstream already reports the full-GPU sentinel. Clear the health-control file and reinstall the plugin after the health tests so a later file does not replay XID 79 as fatal.
Signed-off-by: Vishal Anarase <iamvishalanarase@gmail.com>
kubernetes-prowBot
added
size/XL
Denotes a PR that changes 500-999 lines, ignoring generated files.
and removed
size/XXL
Denotes a PR that changes 1000+ lines, ignoring generated files.
labels
Nov 25, 2026
The changes add JSON-configured XID events and recovery actions to mock NVML, patch the mock engine to expose them, and integrate the patches into GPU setup. The e2e workflow conditionally enables DRADeviceTaints based on Kubernetes version. New BATS tests check XID taints, recovery-action updates, and ignored XIDs.
Merge Risk: Low · up to 31dc6
This PR adds mock-NVML health-check e2e coverage and does not change driver behavior. One test does not actually prove that a NoSchedule taint persists after the GPU recovery action changes to NONE. The weakness is limited to CI test confidence and can be fixed by injecting a later XID before asserting.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: mock-NVML support for XID and recovery-action events, used for GPU health e2e tests. The changeset adds health-control parsing, a build-time patch to the mock NVML sou…
Description check
The description is on topic. It explains why the CPU-only mock-NVML CI cannot exercise GPU health checks, describes the health-control JSON file, the build-time patch, the new bats tests, and the DRAD…
Linked Issues check
Directly linked issue #1457 is the only active target. Its coding requirements and the implementing changes are:
- Configurable XID events with GPU, GI, and CI [#1457]: healthcontrol/control.go par…
Out of Scope Changes check
All changed files support the mock-NVML GPU health-check objective of #1457:
The title names the main change: mock-NVML support for XID and recovery-action events, used for GPU health e2e tests. The changeset adds health-control parsing, a build-time patch to the mock NVML source, and bats tests for GPU health taints, which all match the title.
Full details: Description check
Explanation
The description is on topic. It explains why the CPU-only mock-NVML CI cannot exercise GPU health checks, describes the health-control JSON file, the build-time patch, the new bats tests, and the DRADeviceTaints change for Kubernetes 1.35 and earlier. These match the changed files.
Full details: Linked Issues check
Explanation
Directly linked issue #1457 is the only active target. Its coding requirements and the implementing changes are:
Configurable XID events with GPU, GI, and CI [#1457]: healthcontrol/control.go parses HealthEvent{GPU, XID, GPUInstanceID, ComputeInstanceID}. Omitted instance IDs default to FullGPUInstanceID (0xFFFFFFFF). overlay/engine_hooks.go claims the next event through ClaimHealthControlEvent. patch_mock.py inserts that claim before the pending-XID claim.
Configurable NVML_FI_DEV_GET_GPU_RECOVERY_ACTION [#1457]: patch_mock.py adds recovery-action lookup for field ID 230 in GetFieldValue. HealthStore.RecoveryAction supplies the per-GPU value.
Tests for NONE and GPU_RESET [#1457]: tests/bats/test_gpu_health.bats covers NONE publishing gpu.nvidia.com/xid with effect None, and GPU_RESET publishing effect NoSchedule.
Informational None versus sticky NoSchedule taints [#1457]: the GPU_RESET test checks that the taint persists after the mock reports NONE.
--additional-xids-to-ignore override [#1457]: the suite checks that the GPU_RESET XID stays informational when ignored.
Simulated recovery back to NONE [#1457]: HealthStore rereads the file on each query, so a later rewrite changes the action.
The unit tests in control_test.go cover parsing, default instance IDs, action names, claim-once behavior, and the last-valid-document rule. Tests for the health-control path are present as well.
Scope limit: this review relies on the PR summary and the diff summary. The bats and mock behavior were not executed. The results of the e2e run are not established by this review.
Full details: Out of Scope Changes check
Explanation
All changed files support the mock-NVML GPU health-check objective of #1457:
hack/ci/mock-nvml/healthcontrol/*: health-control parsing, store, overlay hooks, and build-time patcher.
hack/ci/mock-nvml/apply-health-control.sh, setup-mock-gpu.sh, setup-mock-gpu-in-kind.sh: wire the patch into the mock build and builder container, including the python3 prerequisite.
hack/ci/mock-nvml/e2e-test.sh: enables DRADeviceTaints on Kubernetes 1.35 and earlier, so ResourceSlice taints are stored. Taints are required by the tests.
.github/workflows/mock-nvml-e2e.yaml: changes the pinned NVIDIA/k8s-test-infra commit. The patched mock depends on this pin. The new pin is not independently verified in this review.
tests/bats/Makefile: adds test_gpu_health.bats to the mock-NVML suite.
.gitignore: excludes Python bytecode generated by the patcher and its tests. This is a minor supporting change.
No change is unrelated to the issue.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
The reason will be displayed to describe this comment to others. Learn more.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
Other comments: 1
tests/bats/test_gpu_health.bats: 1
164-168: Minor · Functional Correctness · Quick win
Observe the NONE recovery action before asserting that the taint is sticky.
The driver reads the recovery action only while it handles an XID (cmd/gpu-kubelet-plugin/device_health.go:513). This test writes NONE for gpu:1 but injects no later XID. The driver never reads NONE, so the NoSchedule assertion passes on the taint from the earlier event. The assertion cannot show that the taint survives recovery. It also passes if the driver ignores NONE.
After writing NONE, inject a later XID on gpu-1. Wait until the driver has handled that event before asserting NoSchedule. Use a positive-condition wait, not the fixed sleep 3, so the test does not depend on elapsed time.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cncf-cla: yesIndicates the PR's author has signed the CNCF CLA.kind/featureCategorizes issue or PR as related to a new feature.release-note-noneDenotes a PR that doesn't merit a release note.size/XLDenotes a PR that changes 500-999 lines, ignoring generated files.
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind feature
What this PR does / why we need it:
CPU-only mock-NVML CI cannot exercise GPU health checking. The pinned mock emits at most one failure-injector XID, always with GPU instance and compute instance
0, and it does not implementNVML_FI_DEV_GET_GPU_RECOVERY_ACTION. This driver ignores instance0for a full GPU and classifies an XID from the recovery action, so those tests never observe a taint.The mock setup now patches the pinned library at build time. Tests write
/driver-root/health-control.jsonin the GPU plugin container. Each event sets the GPU, XID, GPU instance, and compute instance. Omitted instance IDs mean the full GPU (0xFFFFFFFF).recoveryActionsacceptsGPU_RECOVERY_ACTION_NONE,GPU_RESET, and the other NVML recovery actions, and a later rewrite of the file moves a GPU back toNONEfor a future taint-removal test.tests/bats/test_gpu_health.batsruns in the mock-NVML suite and checks:GI=3,CI=1) is not applied to the full GPU.NONEpublishesgpu.nvidia.com/xidwith effectNone.GPU_RESETpublishes effectNoSchedule, and that taint remains after the mock reportsNONEagain.--additional-xids-to-ignorekeeps aGPU_RESETXID informational.On Kubernetes 1.35 and earlier, the Kind cluster enables
DRADeviceTaintsso those ResourceSlice taints are stored.Which issue(s) this PR is related to:
Fixes #1457
Special notes for your reviewer:
The health-control sources live in this repo and are copied into the pinned
k8s-test-inframock checkout duringsetup-mock-gpu.sh.nvmlDeviceGetFieldValuesstill returns the historical not-supported stub unless the caller asks for field230(NVML_FI_DEV_GET_GPU_RECOVERY_ACTION).AI assistance was used to draft this change.
Does this PR introduce a user-facing change?
Additional documentation (design docs, usage docs, etc.):
Checklist
make check testpasses locallymake check-generatepasses ifapi/changed (CRDs, deepcopy, informers, listers, clientset)make check-modulespasses ifgo.mod/go.sumchangeddeployments/helm) updated if flags, RBAC, or defaults changed