← Back to Pull requests

Use ClusterPolicy defaultWorkload when labeling sandbox nodes #3159

Closed
unknown closed this pull request without merging on Nov 25, 2026 19:53 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 23:16 UTC
Author

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:

if cp != nil {
		sandboxMode = cp.Spec.SandboxWorkloads.Mode
		defaultConfig = getDefaultWorkloadConfig(&cp.Spec.SandboxWorkloads)
	}

...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:

local-agadiyar@ipp1-3037:~/gpu-operator$ kubectl get clusterpolicy cluster-policy -o jsonpath='{.spec.sandboxWorkloads}{"\n"}'
{"defaultWorkload":"vm-passthrough","enabled":true,"mode":"kubevirt"}
local-agadiyar@ipp1-3037:~/gpu-operator$ kubectl get node ipp1-3037 \
  -L nvidia.com/gpu.workload.config \
  -L nvidia.com/gpu.deploy.device-plugin \
  -L nvidia.com/gpu.deploy.vfio-manager \
  -L nvidia.com/gpu.deploy.sandbox-device-plugin
NAME        STATUS   ROLES           AGE    VERSION   GPU.WORKLOAD.CONFIG   GPU.DEPLOY.DEVICE-PLUGIN   GPU.DEPLOY.VFIO-MANAGER   GPU.DEPLOY.SANDBOX-DEVICE-PLUGIN
ipp1-3037   Ready    control-plane   6d5h   v1.31.0                         true                                                 
local-agadiyar@ipp1-3037:~/gpu-operator$ kubectl -n gpu-operator logs deploy/gpu-operator | grep -m1 'failed to get GPU workload config' | grep -o '"defaultGPUWorkloadConfig":"[^"]*"'
"defaultGPUWorkloadConfig":"container"

...no longer seeing the mismatch with the fix:
local-agadiyar@ipp1-3037:~/gpu-operator$ kubectl get clusterpolicy cluster-policy -o jsonpath='{.spec.sandboxWorkloads}{"\n"}'
{"defaultWorkload":"vm-passthrough","enabled":true,"mode":"kubevirt"}
local-agadiyar@ipp1-3037:~/gpu-operator$ kubectl get node ipp1-3037 \
  -L nvidia.com/gpu.workload.config \
  -L nvidia.com/gpu.deploy.device-plugin \
  -L nvidia.com/gpu.deploy.vfio-manager \
  -L nvidia.com/gpu.deploy.sandbox-device-plugin
NAME        STATUS   ROLES           AGE    VERSION   GPU.WORKLOAD.CONFIG GPU.DEPLOY.DEVICE-PLUGIN   GPU.DEPLOY.VFIO-MANAGER   GPU.DEPLOY.SANDBOX-DEVICE-PLUGIN
ipp1-3037   Ready    control-plane   6d5h   v1.31.0                            true                      true
local-agadiyar@ipp1-3037:~/gpu-operator$ kubectl -n gpu-operator logs deploy/gpu-operator | grep -m1 'failed to get GPU workload config' | grep -o '"defaultGPUWorkloadConfig":"[^"]*"'
"defaultGPUWorkloadConfig":"vm-passthrough"

Checklist


  • No secrets, sensitive information, or unrelated changes

  • Lint checks passing (make lint)

  • Generated assets in-sync (make validate-generated-assets)

  • Go mod artifacts in-sync (make validate-modules)

  • Test cases are added for new code paths
  • 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 -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: cdesiniotis Review duration: 32916m
    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
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%