Use ClusterPolicy defaultWorkload when labeling sandbox nodes #3159
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3159"
general
weight: 0.35
cdesiniotis
PROBLEM: This PR is in response to this bug. The operator copies the users choice for gpu.workload.config (container, vm-vgpu, vm-passthrough) into a shared variable defaultGPUWorkloadConfig that starts out as container. The cluster policy controller writes the user's setting into the variable, the node labeling controller reads the variable to decide what variable to use on the node. Both start at the same time, so the labeler won't wait for other controller.
SOLUTION:
_controllers/state_manager.go_ - The shared variable, defaultGPUWorkloadConfig = gpuWorkloadConfigContainer, is removed. A helper function, _getDefaultWorkloadConfig_, that computes the default looks at the ClusterPolicy and returns the user's defaultWorkload if sandbox workloads are on and the value is valid. Otherwise it returns container. Everything that needs the default calls this helper instead of reading a stored value. The function, getWorkloadConfig(...) is updated to take in the default workload config rather than the shared variable.
_controllers/nodelabeling_controller.go_ - In nodelabeling_controller.go, the defaultConfig is set directly from the cluster policy object itself:
...this value is then passed into getWorkloadConfig(...), ensuring that it will be up to date. The value of defaultConfig is no longer dependent on the cluster policy controller (running in parallel) updating defaultGPUWorkloadConfig before it is invoked.
TESTING:
nodelabeling_controller_test.go: New cases in TestUpdateGPUStateLabels check four things with defaultWorkload set in the ClusterPolicy: an unlabeled node gets the vm-passthrough labels, a node that already has them keeps them after a restart, an explicit workload.config label overrides the default, and an invalid default falls back to container; a new TestNodeLabelUpdateReasonsDetectsLabelChanges case checks that adding the workload label triggers a reconcile.
state_manager_test.go: The new TestGetDefaultWorkloadConfig checks that the default comes from the ClusterPolicy only when sandbox workloads are enabled and the value is valid (otherwise it's container), and the new TestGetWorkloadConfig checks that a valid node label wins over the passed-in default, a missing or invalid label falls back to it, and disabled sandbox mode always gives container.
transforms_test.go: A new TestTransformValidatorComponent case checks that the vfio-pci validator's DEFAULT_GPU_WORKLOAD_CONFIG comes from the ClusterPolicy's defaultWorkload, and the existing cases now expect a hard-coded container instead of saving and restoring the deleted global.
Reproduced the mismatch on GPU Operator 26.7.2:
...no longer seeing the mismatch with the fix:
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/3159" 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 -->