← Back to Pull requests

vpa: add TargetConflict status condition for VPAs targeting the same object #10253

Open
unknown opened this pull request with 561 lines diff across 7 files
View on GitHub
unknown unknown commented on Sep 06, 2026 07:18 UTC
Author

/kind feature

What this PR does / why we need it:

If multiple VPAs with an active update mode target the same workload, the admission controller and updater can end up acting on the same pod in different ways. One VPA can try an in-place resize while another evicts the pod.

This adds a TargetConflict status condition so this configuration is visible on the VPA.

How it works:

  • The conflict is detected in the updater, since it is the component that acts on the VPAs.

  • VPAs are grouped by target (namespace, kind, name). Within a group, Stronger() picks the controlling VPA (oldest creation time, then name). This is the same logic the admission controller and updater use to choose a VPA for a pod.

  • Every other VPA in the group gets TargetConflict=True, with a message naming the controlling VPA. The controlling VPA is not modified.

  • VPAs with update mode Off are ignored, unless they have a startupBoost configured, since those still act on pods. Initial and Auto count as active.

  • The condition is cleared when the conflict goes away or the VPA stops being eligible (switched to Off, or no targetRef).

  • The condition is recomputed on each loop, but the status patch is only sent when it actually changed. A Warning event is emitted only when the conflict starts (and a Normal event when it clears), so the updater does not repeat the event every loop.

  • observedGeneration is set on the condition.

  • The updater patches only status.conditions, so it does not touch the recommendation fields owned by the recommender. The patch is guarded with a JSON Patch test op on the existing conditions and retried (up to 3 times, on top of freshly fetched conditions) if another writer changed them in between.
  • RBAC:

  • The updater needs permission to patch verticalpodautoscalers/status. I added the updater service account to the existing system:vpa-status-actor ClusterRoleBinding in deploy/vpa-rbac.yaml.

  • For the Helm chart, I added an updater status-actor ClusterRole and ClusterRoleBinding, kept separate from the recommender's because that one is gated on recommender.enabled.
  • Other:

  • vpaClient in the updater is now vpa_clientset.Interface so the fake client can be used in tests.
  • Which issue(s) this PR fixes:

    Fixes #10135

    Special notes for your reviewer:

  • Earlier revisions detected overlap per container and resource. That does not match real behavior, because Stronger() picks a single VPA per pod regardless of the containers or resources each VPA controls, so this was replaced with controlling-VPA selection.

  • Chart.yaml is not bumped in this PR; it needs a bump before the next release (per discussion).

  • A VPA with no conditions at all is patched without the concurrency guard (JSON Patch has no "path does not exist" test).

  • Conflicts are grouped by namespace, targetRef kind and name (the same key as the admission controller's targetRef index). VPAs that target different owners of the same pods are not detected.
  • Does this PR introduce a user-facing change?

    ``release-note
    Added a
    TargetConflict status condition on VerticalPodAutoscaler objects. When multiple VPAs with an active update mode target the same workload, the oldest VPA controls it, and the others get TargetConflict=True naming the controlling VPA. The updater also emits a Warning event when the conflict starts. The VPA updater now requires permission to patch verticalpodautoscalers/status; the provided deploy manifests and Helm chart are updated.
    `

    Tests

    Table-driven tests in target_conflict_test.go, each also run with reversed input order:

  • Controlling VPA selection: creation time wins over name, name tie-break, three VPAs.

  • Modes: Initial counts as active, Off is ignored, Off with startupBoost is active.

  • Scope: single VPA, same target name in different namespaces, ignored namespaces.

  • Clearing: other VPA gone, controlling VPA's stale condition, VPA turned Off or lost its targetRef.

  • Events: one Warning on new conflict, none while it persists or when the controlling VPA changes, one when a third VPA joins, a Normal event when resolved.

  • Patching: no status patch for an unchanged conflict, one patch for a new, changed or resolved conflict.

  • Concurrency: a condition written by another writer survives, and retries are bounded.
  • gofmt, go build, go vet and the pkg/updater/...` tests pass.

    Diff: 561 lines (+420 / -141) across 7 files Reviewer: yashrajshuklaaa Review duration: 104212m
    All Vouch review confidence checks passed
    Residual risk 0.31 = Change Risk (0.57) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 561 lines diff across 7 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    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.379
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #10253"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% 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: 56.7% (MEDIUM) · Higher = larger blast radius
    56.7%
    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: 44.7% · Lower = rushed or shallow review
    44.7%
    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: 31.3% · Safe to merge
    31.3%