reconcile nvidiadriver when any nodeselector label changes #3003
I don't understand the point of comparing the key presence here. If key is present in one, but absent in the other, won't the values be unequal anyway?
Naive question. Why do we need this for loop L142-153? It's only checking a subset of the labels in oldLabels and newLabels, right? Isn't the L130 equality check more comprehensive thus making this for loop check redundant?
Can we OR this with reasons.needsUpdate() ?
<!-- devin-review-comment {"id": "ANALYSIS_pr-review-job-2ecc357b8faf429ea7224e9588e2fe99_0001", "file_path": "controllers/nodelabeling_controller.go", "start_line": 130, "end_line": 132, "side": "RIGHT", "kind": "analysis"} -->
🔍 Driver lookup on unrelated node updates
Every otherwise untracked node label change lists all NVIDIADrivers, even on non-GPU nodes or when no driver uses that label. Review the event rate before adding this cluster-wide lookup to the predicate.
<!-- devin-review-badge-begin -->
<a href="https://nvidia-cloud.devinenterprise.com/review/nvidia/gpu-operator/pull/3003" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
---
Was this helpful? React with 👍 or 👎 to provide feedback.
Devin Review found 1 potential issue.
<!-- devin-review-badge-begin -->
<a href="https://nvidia-cloud.devinenterprise.com/review/nvidia/gpu-operator/pull/3003" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->
instead of having to break twice, why not return from here instead?
return reasons, nil
Here, we are getting node selectors configured in all non-deleting nvds, since changes to those selector labels can affect node ownership. oldLabels and newLabels are just for the node; they don’t tell us which labels are used by nvidiadriver's nodeSelectors. We need those selectors to determine whether the label change should trigger reconciliation.
Would this work? It feels a bit off to perform a needsUpdate() check on a reasons object that isn't completely filled up.
if !nvidiaDriverOwnerLabelChange && !maps.Equal(oldLabels, newLabels) {
Ah yes, that makes sense. Thank you for the explanation!
fair point, updated the code to return early and make it bit cleaner.
nit: Better to log the error here as opposed to logging at the method call site. From the perspective of the method call site, the error wouldn't be specific.
Thanks @rahulait ! Just one minor comment and it should be good to go after
updated.
/cherry-pick release-26.7
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/NVIDIA/gpu-operator/pull/3003?cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a>
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
<!-- review_stack_entry_end -->
<details>
<summary>🧰 Additional context used</summary>
<details>
<summary>📚 Code guidelines (1)</summary>
AGENTS.md — auto-discovered
</details>
</details>
<!-- recent_review_start -->
No actionable comments were generated in the recent review. 🎉
<details>
<summary>ℹ️ Recent review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
47f7b26d-8774-40a4-b5b5-099644c79fad</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 3e1873a25ef46219f9b2db6f19a0b90818729586 and 787b23d589b6bc2b7ebda154c0c2fedf1c3e6fc9.
</details>
<details>
<summary>📒 Files selected for processing (2)</summary>
controllers/nodelabeling_controller.go
controllers/nodelabeling_controller_test.go
</details>
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
</details>
---
<!-- recent_review_end -->
<!-- walkthrough_start -->
<details>
<summary>📝 Walkthrough</summary>
Walkthrough
Node update detection now checks changed node labels against selector keys from all non-deleting NVIDIADriver resources, rather than only the current owner. It skips driver listing when labels are unchanged or another update reason applies. A driver-list error causes the update to be enqueued. Tests cover selector-label additions, removals, and value changes, as well as deleting drivers and list-call conditions.
</details>
<!-- walkthrough_end -->
<!-- change_assessment_start -->
Priority: ➖ Normal
<!-- change_assessment_commit:"787b23d589b6bc2b7ebda154c0c2fedf1c3e6fc9" -->
Severity of issue fixed: Medium
<!-- change_assessment_end -->
<!-- final_review_risk_start -->
Merge Risk: _⚪ Minimal_ · up to 787b2
<!-- final_review_risk_coverage:{"sourceCommitId":"787b23d589b6bc2b7ebda154c0c2fedf1c3e6fc9","coveredCommitId":"787b23d589b6bc2b7ebda154c0c2fedf1c3e6fc9","kind":"reviewed"} -->
The reviewed label-change detection covers the supported driver selectors, with no actionable merge risk identified. The change is ready for normal merge checks.
<!-- final_review_risk_end -->
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- tips_start -->
---
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
Approved these changes.
🤖 Backport PR created for release-26.7: #3007 ✅
tariq1890
rahulait
Description
Fixes https://github.com/NVIDIA/gpu-operator/issues/3004
<!-- Brief description of the change, including context or motivation -->
Fix node reconciliation when labels used by any NVIDIADriver selector change. Previously, only the current owner’s selector was checked, so unowned or default-owned nodes could remain assigned incorrectly.
Added regression tests for selector label changes and driver pool transitions.
Checklist
make lint)make validate-generated-assets)make validate-modules)Testing
<!-- How was this tested? e.g., unit tests, manual testing on cluster -->
<!-- devin-review-badge-begin -->
---
<a href="https://nvidia-cloud.devinenterprise.com/review/nvidia/gpu-operator/pull/3003" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->