Repository navigation
fix(agent): WARN when an agent closes without completing the handshake - #217
Merged
Merged
Conversation
An agent that upgrades, sends frames but never reaches the authenticated state used to leave no trace at the default log level, while the server kept the half-open session by design. On close, log one WARN line with the received-command bitmask decoded (which of cmd 1/2/3/4 arrived, which is missing) or, once the cert is verified, the hold reason from setAgentIssue; include the remote address, frame count, authenticated value and lifetime, count it in agentStats and export it to Prometheus as HandshakeIncomplete. Progress is tracked in obj.diagStage (0 nothing verified, 1 cert verified, 2 fully authenticated) and the address is snapshotted at connect, because obj.close() deletes nodeid/remoteaddrport before the 'close' event fires. WARN lines are capped at 20 per minute with a suppressed count. The existing DEBUG close line stays unconditional. No behaviour change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Author
🦩 Flamingo Code Review✅ No findings on the current head. Advisory: findings do not block the merge. 3 possible problems checked and ruled out
Review again. New commits are not reviewed until you ask:
Or comment Started 2026-10-07 21:25 UTC · updated 2026-10-07 21:26 UTC · workflow run |
danylo-babenko-flamingo
approved these changes
Oct 8, 2026
denys-gif
approved these changes
Oct 8, 2026
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.
Summary
An agent that upgrades, sends frames but never reaches the authenticated state used to leave no trace at the default log level, while the server kept the half-open session by design (fix256, 2026-10-07: the agent's cmd 2 never arrived, node never created, 15 h offline, nothing in the pod log).
On close of such a connection,
meshagent.jsnow logs one WARN line, visible at the tenant defaultMESH_LOGGING=INFO:receivedCommandsbitmask decoded, e.g.got cmd1 (auth request), cmd3 (agent info), cmd4 (auth confirm, optional); missing cmd2 (cert+signature);cert verified but connection never completedplus the hold reason recorded bysetAgentIssue(unknown device group, bad signature, duplicate agent, ...);authenticatedvalue, lifetime.Details:
obj.diagStageand the address is snapshotted at connect, becauseobj.close()deletesnodeid/remoteaddrportbefore the'close'event fires (the close listener survivesremoveAllListeners([...])), so authenticated agents closed by the server are never miscounted;agentStats.agentHandshakeIncompleteCount, exported to Prometheus asHandshakeIncomplete.Log only. No handshake deadline and no socket close, as agreed in the Slack thread.
Test
Drove the real
CreateMeshAgentclose handler with stubbed sockets: fix256 shape warns withmissing cmd2; a held-after-verification server close warns withissue=invalidDomainMesh2and an intact address; an authenticated agent closed by the server stays DEBUG-only; a zero-frame upgrade stays silent; the throttle logs 20 of 25 and reports+5 similar suppressed.node --checkpasses on all three files.CU-17tkuw5vmhq
Change-Set: mesh-handshake-incomplete-warn
🤖 Generated with Claude Code
Change set
flamingo-stack/mesh-handshake-incomplete-warn: this pull request is the only one in it so far. Another pull request joins by naming this one in aDepends-Online, or by carrying the sameChange-Setline.Linked work
Linked by the
Depends-On/Change-Setlines in these descriptions; this block is maintained by the hub.