← Back to Pull requests

fix: allow empty-string topology spread domains #3317

Open
maxcao13 opened this pull request with 46 lines diff across 2 files
View on GitHub
maxcao13 maxcao13 commented on Sep 15, 2026 02:38 UTC
Author

Fixes #3146

Description

When a topology spread constraint uses a label whose value is the empty string (e.g. node-role.kubernetes.io/worker: ""), Karpenter registers that domain but nextDomainTopologySpread treats minDomain == "" as failure and returns DoesNotExist. Pods with whenUnsatisfiable: DoNotSchedule stay pending even though the domain is valid and has headroom under maxSkew.

The fix checks validDomains.Len() == 0 as the failure condition instead. An empty string is a legitimate domain value since a domain is effectively defined as a <key, value> pair (i.e. a label), and according to official Kubernetes docs, a label value is entirely valid to be an empty string.

After this fix, we still continue to accept that the _absence_ of any valid domain (including domains with empty string value) should still produce DoesNotExist.

How was this change tested?

Added two unit tests in topology_test.go:

Provisions 2 pods with a TSC on a custom label where the only domain is "". Before the fix, both pods stayed pending. After, both schedule to that domain (skew: [2]).
Provisions 4 pods with a TSC across two NodePools: one with domain "", one with domain "worker". Verifies pods spread evenly across both (skew: [2, 2]).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Diff: 46 lines (+44 / -2) across 2 files Reviewer: semx Review duration: 43629m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.27) × (1 − Review Confidence (0.86)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.27 · 46 lines diff across 2 files
0.27
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 4 substantive comment(s)
0.91
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
86%
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.230
Real PR Conversation Timeline
6 items
kubernetes-prow[bot] kubernetes-prow[bot] commented on Sep 15, 2026 02:38 UTC
Bot

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/karpenter/pull/3317#" title="Author self-approved">maxcao13</a>
Once this PR has been reviewed and has the lgtm label, please assign engedaam for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

<details open>
Needs approval from an approver in each of these files:

  • OWNERS
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":["engedaam"]} -->

    maxcao13 maxcao13 commented on Sep 15, 2026 02:49 UTC
    Author

    /cc @DerekFrank

    this is the simple proposed fix after talking about issue in the wg on sept 10, 2026.

    PTAL and please tag anyone anyone else that needs to review/be aware, thanks!

    semx semx commented on Sep 18, 2026 07:52 UTC
    Reviewer

    Read nextDomainTopologySpread on main and reproduced both new specs failing there.

  • minDomain starts as "" and is assigned in the same branch that inserts into validDomains, with minCount starting at MaxInt32, so validDomains.Len() == 0 is exactly "no domain selected" and no longer conflates a legitimately selected "". domainMinCount and TopologyGroup.Register do not special-case "".

  • An In [""] requirement is valid downstream: the NodeClaim CRD values pattern ^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$ accepts the empty string and validation.IsValidLabelValue("") returns no errors (nodeclaim_validation.go:136). envtest applied the real CRDs, so the NodePool template label with an empty value is accepted too.

  • Both specs fail on main with nodeDomains = topology.example.com/role In [] and pass here; full package green with -race.
  • One nit: the deleted comment explained why the old check existed. A one-line replacement saying that "" is a valid domain value would keep someone from reintroducing the minDomain == "" check later.

    GnatorX GnatorX commented on Oct 08, 2026 18:33 UTC
    Contributor

    LGTM too

    maxcao13 maxcao13 commented on Oct 13, 2026 18:35 UTC
    Author

    added a comment explaining the change, PTAL!

    /cc @jmdeal

    Reviewers
    Assignees
    maxcao13 maxcao13
    Labels
    risk: low confidence: 86.1% 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: 27.5% (LOW) · Higher = larger blast radius
    27.5%
    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: 86.1% · Lower = rushed or shallow review
    86.1%
    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: 3.8% · Safe to merge
    3.8%