← Back to Pull requests

fix(nodepool-controller): write a fractional fair-share window size as a Prometheus duration #214

Open
unknown opened this pull request with 358 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 16, 2026 00:05 UTC
Author

Description

The NodePool CRD admits a fair-share window size with a fraction or with units in
any order (1.5d, 0.5d, 2.5h, 30m2h). Its pattern is
^(0|([0-9]+(\.[0-9]+)?(m|h|d))+)$.

The controller copies that string unchanged into the SchedulingShard's
usageParams.windowSize. That field is a Prometheus duration: whole numbers,
units largest first. The SchedulingShard CRD pattern rejects these values, so
the API server refuses the shard write. Following the reconcile code, a new node
pool then stays Unschedulable with only the generic scheduler-not-ready message,
and an existing pool's shard stops taking updates. I have not run this on a
cluster; the rejection itself is shown below with the API server's schema
validator.

parseMonitoringDurationParam now behaves as follows:

  • A value Prometheus can already read (7d, 14d, 168h) is kept as written.

  • A value only str2duration can read is converted with model.Duration; KAI

  • Scheduler reads this field with model.ParseDuration. 1.5d becomes 1d12h, and 30m2h
    becomes 2h30m.
  • Anything else still falls back to the default window, as before.
  • github.com/prometheus/common was already in the module graph. It moves from an
    indirect to a direct requirement.

    Related issues

    None.

    Checklist

  • Self-reviewed the complete diff

  • Added or updated tests where needed

  • Updated user and developer documentation where needed (no doc change: the documented behaviour, a window "length", is what now happens)

  • Ran make validate (mod-check, license-check, header-format-check, notice-check, sync-crds-check and crd-rbac-check pass, as do gofmt and go vet; I could not run the lint and scc-check targets locally)

  • Added a changelog fragment for a behavior change, or explained why none is needed

  • Confirmed new third-party code retains provenance and licensing
  • Breaking changes

    None. Window sizes that were already valid Prometheus durations are written
    unchanged.

    Additional notes

    Tests:

  • Two new cases in the existing "with custom Window.Size" specs: 1.5d must give

  • 1d12h, and 30m2h must give 2h30m. Both fail on main, where the shard
    receives 1.5d and 30m2h, and pass with this change.
  • The existing 14d, 168h and invalid-value cases are unchanged and still pass.

  • go test ./pkg/... ./cmd/... passes.
  • I also validated the shard the controller builds against the pinned
    SchedulingShard CRD (github.com/kai-scheduler/api@v0.1.4), using the API
    server's schema validator from k8s.io/apiextensions-apiserver:

  • Before this change, 1.5d, 0.5d, 2.5h and 12h1d were rejected.

  • After it, all of them are accepted and parse back to the same length with

  • model.ParseDuration.

    This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.

    Diff: 358 lines (+268 / -90) across 4 files Reviewer: blacksoxx Review duration: 9820m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.43) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 358 lines diff across 4 files
    0.43
    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%
    42%
    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.352
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #214"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 42.6% (MEDIUM) · Higher = larger blast radius
    42.6%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 24.3% · Safe to merge
    24.3%