← Back to Pull requests

vxpu/router: expire idle instances and stop reconcile loop cleanly #866

Closed
unknown closed this pull request without merging on Nov 24, 2026 04:12 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 02:30 UTC
Author

Handle keep-alive expiry and clean shutdown for instances owned by
ModelReconciler, deferred from #842.

Keep-alive expiry on resync (no per-instance timers):

  • Start an instance's idle clock only when its current generation first

  • reaches Passed, not while it is NotLoaded (waiting in the queue or
    waiting for pod scheduling), Loading, or Checking. A resync reload of
    the same generation after executor eviction does not reset the clock.
  • Store per-instance monotonic activity timestamps (*atomic.Int64 in a

  • sync.Map) so Touch on the serving request hot path (executorEndpoint,
    GetVocab cache hits, proxyChat completion, streamed proxyGenerate
    chunks, and matching SetDesired calls) performs one lock-free lookup
    and one atomic store without acquiring r.mu or contending with
    readers or the reconcile loop.
  • Check idle expiry during the existing periodic resync pass against

  • the keep-alive duration (defaulting to VXPU_EXECUTOR_KEEP_ALIVE /
    3600s, configurable via WithKeepAlive).
  • When an instance expires, remove its desired state and enqueue it

  • for teardown so the reconcile loop closes pooled connections and
    deletes its executor pod once and leaves it down through later
    resyncs.

    Clean shutdown and restart pod adoption:

  • Track all reconciler background goroutines (worker, resync/shutdown

  • watcher, and async manifest rewrites) with a WaitGroup so Stop
    cancels in-flight work, wakes blocked Wait callers with Unavailable,
    shuts down the work queue, and waits for all goroutines to exit
    before returning.
  • Respect context cancellation in getOrStartPod's pod-readiness wait

  • loop so shutdown returns promptly even while a pod is Pending.
  • Close the local blobserver in Server.Close.

  • Leave executor pods and their running processes up on shutdown by

  • design, logging that they were left running for adoption after a
    restart. Document this behavior and what a restarted router does
    with pre-existing pods (adopts matching pods on LoadModel, replaces
    mismatched image/placement pods, and leaves unrequested pods
    untouched) in vxpu/docs/design.md.

    Tests under -race verify idle expiry deletes the pod once and stays
    down across resyncs, serving requests extend the keep-alive window,
    slow pod scheduling longer than keep-alive does not expire an instance
    before it passes, shutdown returns promptly with no reconciler or
    workqueue goroutines left running, and a restarted router adopts
    matching pods and replaces mismatched ones.

    Fixes #864

    Diff: 311 lines (+233 / -78) across 3 files Reviewer: codebot-robot Review duration: 102m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 311 lines diff across 3 files
    0.40
    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.344
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #866"
    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: 40.3% (MEDIUM) · Higher = larger blast radius
    40.3%
    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: 17.4% · Safe to merge
    17.4%