Repository navigation
fix(spire): count the node identity's unchanged SVID updates so the metric's zero is real (#993) - #1011
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mechanism
aether_agent_spire_svid_updates_total{aether_spire_identity="node",aether_spire_update="unchanged"}is seeded at 0 on every node (#717), butrefreshNodeSVIDinagent/internal/spire/bridge.go:// unchanged; avoid a no-op snapshot bump) without recording anything, andinitialOrRotated(firstServe).So the node
unchangedseries could never move, and a gate reading zero there was vacuous. The pod path already classifies by comparing bytes, and itsunchangeddoes 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 isrotated, and the same chain+key isunchanged.unchangedis counted and still returns early, so there is no snapshot bump and no push.unchangedis counted only when SPIRE actually delivered the SVID. That means the refresh was woken by the source'sUpdated()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/refreshNodeSVIDnow take adeliveredflag thatrunIdentityRefreshsets on theUpdated()wake.Own-bundle path: checked; it does not have this problem.
bundle_updatesseeds onlyinitial/rotated(forownandfederatedalike), so nounchangedseries exists that could sit at a meaningless zero. I added a comment at its early return saying so.Docs:
docs/runbook.mdnow says nodeunchangedis 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, sincepod/unchangedmoved at the JWT-key prepare.e2e/soak/README.mdsays a nodeunchangedzero from a pre-#993 build is no evidence. The metric description and const comment inmetrics.goare updated to match.docs/configuration.mddoesn'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:runIdentityRefreshplus the fake source'sUpdated()channel.node/initial=1 andnode/unchanged=1, with no generation bump and noSetSecretspush.node/rotated=1,unchangedstays 1, and the generation bumps.Red: I ran the test on unmodified
origin/mainbridge.go(the fix reverted, only the new test file added). It uses onlyrunIdentityRefresh, so it compiles against both signatures:The
initialassertion before it passed. With the fix it is green, and 20/20 in--runs_per_test=20.TestNodeIdentityUpdateClassificationis extended: three backstop reads (delivered=false) leavenode/unchangedat 0, one delivered equal read makes it 1, and a delivered rotation leaves it at 1.Local:
bazel test --config=race //agent/internal/spire:allpasses;bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/...is clean;bazel run //:formatproduced no diff.Closes #993
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr