Skip to content

fix(registrar,controller,edge): NotReady until identity, not after a dwell (#740) - #744

Merged
bpalermo merged 1 commit into
mainfrom
fix/740-pr4-deployment-readiness
Sep 7, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/740-pr4-deployment-readiness

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 7, 2026

Copy link
Copy Markdown
Owner

PR 4 of #740. PRs 1-3 (#741, #742, #743) made every binary survive a SPIRE that
is still coming up. This one fixes what PR 2 got wrong about the Deployments.

The observation

On the rev210 upgrade roll, 2026-09-07 20:03:45Z, a registrar Pod was in its
Service's endpoints before it had an SVID — PR 2 gave the registrar and the
controller the agent's 2 m spire-svid dwell, so the replica reported Ready for
the first two minutes of its wait. An agent on main-worker-01 dialled it and
could not handshake:

transport: authentication handshake failed: x509svid: could not get X509 bundle

which surfaced as two ERROR lines, for one transient that healed on its own:

ERROR failed to start watch stream, retrying            registry/internal/registrar/registrar.go:574
ERROR failed to refresh clusters from registry          agent/internal/xds/server/refresh.go:193

Why the dwell is agent-only

The agent's dwell is not a general tolerance for a slow SPIRE. It exists for
exactly one reason: NotReady on the agent DaemonSet is the signal the
controller's node-taint guard consumes (proposal 033), so a gate that failed from
t=0 would turn a 40 s SPIRE hiccup into a fleet-wide aether.io/agent-not-ready
taint. That is a fleet-level action, and the dwell is the guard against it.

The registrar, controller and edge are Deployments behind Services. NotReady
there means one thing — take this replica out of the endpoint set — and that is
precisely the correct handling of a pod that cannot complete an mTLS handshake.
A replica that cannot handshake has no business being dialled.

Component Workload Dwell What NotReady does
aether-agent DaemonSet 2 m (NotReadyDwell) node-taint guard re-arms aether.io/agent-not-ready:NoSchedule
aether-registrar Deployment 0 (ServiceNotReadyDwell) leaves the registrar Service's endpoints
aether-controller Deployment 0 leaves the webhook Service's endpoints
aether-edge Deployment 0 leaves the LoadBalancer's endpoints

The edge is included deliberately: it serves ingress behind the MetalLB LB
Service, and a second replica goes on serving while this one waits.

spire.ReadyChecker now takes the dwell as a parameter rather than reusing
the wait's WARN threshold. The two questions — "how long before this wait is
worth waking someone for" and "how long before NotReady is the right answer" —
only ever shared a value on the agent. --spire-wait-warn-after is now a logging
threshold only; the WARN/INFO escalation on the wait itself is unchanged, as is
the once-per-transition readiness logging on the agent.

The classification change

The other half of the observation is the agent's own reaction. When our identity
is ready but the peer rejects the handshake for want of its own, that is the
server's startup — not a client fault, and not the "registrar will not serve this
stream" condition #700 made those ERRORs for. New
common/spire.IsPeerIdentityUnavailable recognises it (could not get X509 bundle / x509svid:, matched on the whole error so a gRPC status carrying the
handshake failure matches too), and both paths treat it the way #718 treats a
drain GOAWAY:

  • watch loop → INFO registrar has no identity yet; retrying
    (peer_identity_pending=true), no watch_errors, bounded backoff. It
    does escalate the backoff, unlike the own-identity deferral from fix(agent): wait for the SPIRE Workload API instead of dying on it (#740) #741:
    nothing wakes this loop when the far side acquires its SVID, so it has to keep
    polling, and the doubling — capped at maxBackoff — is what stops a genuinely
    dead registrar from being polled every second forever.
  • cluster refresh → WARN cluster refresh deferred: the registrar has no identity yet, keeping the current snapshot, no refresh_errors. Every
    other reload failure keeps ERROR and the counter: those leave the cluster
    snapshot stale until the next change signal (reloads are not retried), which is
    the condition refresh_errors exists to surface, and burying it under a boot's
    worth of handshake noise is what this avoids.

The peer check runs after the existing local identityPending() check, so a
client with no certificate of its own never blames the server.

Tests

  • common/spire: the readiness table gains the dwell dimension (nil source,
    SVID-in-hand, waiting — each on both dwells), plus TestServiceNotReadyDwellIsZero
    pinning that the two dwells differ deliberately. TestIsPeerIdentityUnavailable
    covers the literal rev210 gRPC status, the bare go-spiffe error, and the
    negative controls: our own ErrNoSVIDYet, a connection-refused dial, a drain
    GOAWAY.
  • Call sites: the registrar, controller and edge readiness tables now assert
    NotReady with no SVID; the edge additionally asserts that an hour-long
    --spire-wait-warn-after does not keep it Ready (the flag no longer drives the
    gate).
  • registry/internal/registrar: TestWatchLoop_DefersWhilePeerHasNoIdentity
    runs the client against a fake registrar whose mTLS handshake fails with the
    observed error while the client's own identity is ready — asserting the INFO
    level, peer_identity_pending=true, no ERROR of any kind, and no
    watch_errors sample. TestDeferPeerStreamBoundsTheBackoff pins the doubling
    and the cap.
  • agent/internal/xds/server: reportReloadFailure is tested for level and
    counter on the identity transient (WARN, no counter), on a real failure (ERROR,
    counter = 1), and with instrumentation disabled.

Chart

No template change. values.yaml's spire.waitWarnAfter comment claimed the
dwell applied "on all four components", which is now false — corrected, with a
PATCH bump to 0.92.12 (comment-only chart changes are CI-enforced to bump).

Runbook

docs/runbook.md gains a per-component readiness table in "stuck waiting for
SPIRE", states that the agent's dwell is a taint-guard artefact rather than a
general tolerance, and the three Deployment bullets now say NotReady for the
whole wait. The registrar bullet documents both new log lines.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…dwell (#740)

PR 4 of #740. The readiness dwell PR 2 gave the registrar, controller and edge
is the agent's dwell, and it is wrong for a Deployment.

Observed on the rev210 upgrade roll (2026-09-07 20:03:45Z): a registrar Pod was
in its Service's endpoints before it had an SVID, so an agent on main-worker-01
dialled a replica that could not handshake and logged two ERRORs for it —
`failed to start watch stream, retrying` (registrar.go:574) and `failed to
refresh clusters from registry` (server/refresh.go:193), both carrying
`transport: authentication handshake failed: x509svid: could not get X509
bundle`.

The agent's dwell is not about the agent tolerating a slow SPIRE. It exists
solely because NotReady on the agent DaemonSet is the signal the controller's
node-taint guard consumes, and a taint is a fleet-level action a 40s hiccup must
not trigger. Nothing behind a Service has that coupling: there NotReady removes
one replica from one endpoint set, which is precisely the correct handling of a
pod that cannot complete an mTLS handshake.

So `spire.ReadyChecker` now takes the dwell as a parameter instead of reusing the
wait's WARN threshold — the two questions were only ever the same value on the
agent. The agent keeps `NotReadyDwell` (2m); the registrar, controller and edge
register `spire-svid` with the new `ServiceNotReadyDwell` (0). The edge included:
it serves ingress behind the MetalLB LoadBalancer, where a second replica goes on
serving while this one waits. The WARN/INFO escalation on the wait itself is
unchanged, and `--spire-wait-warn-after` is now a logging threshold only.

The agent side of that handshake failure is reclassified too. When our OWN
identity is ready but the peer rejects the handshake for want of its own,
`common/spire.IsPeerIdentityUnavailable` recognises it and both paths treat it
like #718's drain GOAWAY — the server's startup, not a client fault:

  - the watch loop logs INFO `registrar has no identity yet; retrying`, counts no
    `watch_errors`, and retries on a bounded (doubling, capped at maxBackoff)
    backoff. It escalates where the own-identity deferral does not, because
    nothing wakes this loop when the FAR side acquires its SVID.
  - the cluster refresh logs WARN `cluster refresh deferred: the registrar has no
    identity yet, keeping the current snapshot` and counts no `refresh_errors`.
    Every other reload failure keeps ERROR and the counter: those leave the
    cluster snapshot stale until the next change signal, which is the condition
    the counter exists to surface.

Tests: the readiness table gains the dwell dimension plus a pin that the two
dwells differ deliberately; the three call-site tables assert NotReady with no
SVID (the edge additionally that a long warn-after does not keep it Ready); a
fake registrar whose mTLS handshake fails with the observed error asserts the
INFO line, the absent counter and the bounded backoff; and the refresh path is
tested for level and counter on both the identity transient and a real failure.

Runbook: a per-component readiness table in "stuck waiting for SPIRE", and the
Deployment bullets now say NotReady for the whole wait. Chart: values.yaml
comment corrected, PATCH bump to 0.92.12.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant