Skip to content

fix(spire): count the node identity's unchanged SVID updates so the metric's zero is real (#993) - #1011

Merged
bpalermo merged 2 commits into
mainfrom
fix/993-node-svid-unchanged
Sep 27, 2026
Merged

bpalermo merged 2 commits into
mainfrom
fix/993-node-svid-unchanged

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Mechanism

aether_agent_spire_svid_updates_total{aether_spire_identity="node",aether_spire_update="unchanged"} is seeded at 0 on every node (#717), but refreshNodeSVID in agent/internal/spire/bridge.go:

  • returned early on an SVID whose chain+key equal the one served (// unchanged; avoid a no-op snapshot bump) without recording anything, and
  • classified every other update with initialOrRotated(firstServe).

So the node unchanged series could never move, and a gate reading zero there was vacuous. The pod path already classifies by comparing bytes, and its unchanged does move (SPIRE re-sends every SVID fleet-wide at a JWT-key prepare).

Fix

The node path now classifies the same way as the pod path: the first serve is initial, a different chain+key is rotated, and the same chain+key is unchanged. unchanged is counted and still returns early, so there is no snapshot bump and no push.

unchanged is counted only when SPIRE actually delivered the SVID. That means the refresh was woken by the source's Updated() channel, which go-spiffe's watcher fires on every Workload API X509 response (OnX509ContextUpdate → triggerUpdated), changed or not. The 30s backstop tick re-reads a cached value and is not a delivery. Counting it would add about 2/min/node forever, so the counter would track the ticker instead of redeliveries. This matches the pod path, which counts Broker responses and not polls. refreshIdentity/refreshNodeSVID now take a delivered flag that runIdentityRefresh sets on the Updated() wake.

Own-bundle path: checked; it does not have this problem. bundle_updates seeds only initial/rotated (for own and federated alike), so no unchanged series exists that could sit at a meaningless zero. I added a comment at its early return saying so.

Docs: docs/runbook.md now says node unchanged is real, spells out what it counts (deliveries only, never the backstop re-read), and adds a paragraph: a zero series is only evidence once the path can increment it. The known-unexercised table row is also scoped: the dropped-Broker-stream trigger is still unexercised, but the series has fired, since pod/unchanged moved at the JWT-key prepare. e2e/soak/README.md says a node unchanged zero from a pre-#993 build is no evidence. The metric description and const comment in metrics.go are updated to match. docs/configuration.md doesn't mention the metric, so it is unchanged.

Gate, seen red

New TestNodeSVIDRedeliveryCountsUnchanged (agent/internal/spire/bridge_node_unchanged_test.go) drives the real wake path: runIdentityRefresh plus the fake source's Updated() channel.

  • Same node SVID delivered twice: node/initial=1 and node/unchanged=1, with no generation bump and no SetSecrets push.
  • A new certificate: node/rotated=1, unchanged stays 1, and the generation bumps.

Red: I ran the test on unmodified origin/main bridge.go (the fix reverted, only the new test file added). It uses only runIdentityRefresh, so it compiles against both signatures:

--- FAIL: TestNodeSVIDRedeliveryCountsUnchanged (5.00s)
    bridge_node_unchanged_test.go:62: Condition never satisfied
        Messages: a redelivered, byte-identical node SVID must count as unchanged (issue #993)

The initial assertion before it passed. With the fix it is green, and 20/20 in --runs_per_test=20.

TestNodeIdentityUpdateClassification is extended: three backstop reads (delivered=false) leave node/unchanged at 0, one delivered equal read makes it 1, and a delivered rotation leaves it at 1.

Local: bazel test --config=race //agent/internal/spire:all passes; bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/... is clean; bazel run //:format produced no diff.

Closes #993

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 27, 2026 17:34
…etric's zero is real (#993)

refreshNodeSVID returned early on an SVID equal to the one served without
recording anything, and classified every other update with
initialOrRotated, so svid_updates{identity="node",update="unchanged"} was
seeded at zero and could never move.

Classify the node SVID like the pod path: first serve is initial, a
different chain+key is rotated, the same chain+key is unchanged (still no
snapshot bump). unchanged counts only when SPIRE actually delivered the
SVID (the source's Updated channel, which go-spiffe fires on every
Workload API response); the 30s backstop re-read is not a delivery.

The own-bundle path has no hole: bundle_updates seeds no unchanged series.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Resolve the e2e/soak/README.md conflict with #992's SVID-rotation rewrite:
keep main's text and add the #993 note on node/unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 2a16904 into main Sep 27, 2026
24 checks passed
@bpalermo
bpalermo deleted the fix/993-node-svid-unchanged branch September 27, 2026 20:47
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.

spire bridge: node-identity "unchanged" can never fire (bridge uses initialOrRotated), so its zero series is vacuous

1 participant