Skip to content

feat: every overlay peer gets PersistentKeepalive = 25 (keel#140) - #144

Merged
marcos-mendez merged 7 commits into
mainfrom
feat/mesh-keepalive
Oct 16, 2026
Merged

marcos-mendez merged 7 commits into
mainfrom
feat/mesh-keepalive

Conversation

@marcos-mendez

Copy link
Copy Markdown
Collaborator

Follow-up of #143 for #140. Decision: the coordinator's, 2026-10-10. Turn on PersistentKeepalive = 25 for every mesh peer, so that the 180 s handshake drift means "unreachable" and the NAT/firewall state stays open between sites.

Change

  • keel/network/wireguard.py: DEFAULT_KEEPALIVE = 25 and keepalive(). render writes PersistentKeepalive for every peer: the spec's value, else 25.
  • keel/network/switch.py (keepalive_only): keel spec apply sets the keepalive live with wg set. A change that only sets the keepalive of a peer that the interface holds cannot cut the node off, so it counts as an addition does (added_live, keel#117). keel mesh keeps it with no handshake, so the first sync after the upgrade does not wait for one.
  • keel/diff/compare.py (with_overlay_defaults): a peer that gives no keepalive declares 25. A file written before this version is drift (network.overlay.wireguard.peers.<key>.persistent_keepalive) until apply writes it again.
  • Docs: docs/spec.md, docs/diff.md, docs/apply.md. Version 0.23.17 (fix: the old primary turns its database read only before it releases the VIP (keel#138) #142 holds 0.23.16).

Tests

  • tests/test_network_wireguard.py: render and the default.
  • tests/test_inspect_overlay.py: keel diff says same for a file with the line, and drift for a file without it.
  • tests/test_network_overlay_live.py: a change that only sets the keepalive counts as safe; an endpoint change does not.
  • The mesh netns suites (3-node, 4-node, late-add, live-peers) pass locally.

…el#199)

In the release test of LNMP 19.0-3 (2026-10-16), the member on BR2 did
not get the cluster at the third join (the send timed out), and keel
mesh etcd form then said "every ready member is in the cluster".
etcd lists each member of ETCD_INITIAL_CLUSTER with its name, also one
that never ran; such a member has no client URL:

  keel-fd43-1cbe-b5be--65d3 ['https://[fd43:1cbe:b5be::65d3]:2380'] None

The tests ask that such a member is not started, and that keel mesh
etcd form sends the first cluster again to it. A learner that started
publishes its client URLs too, and the fixture now says so.
…er ran (keel#199)

etcdclient.Member.started was bool(name). A member of the first
cluster that never ran is listed with the name of ETCD_INITIAL_CLUSTER,
so keel mesh etcd form never found it, and the cluster stayed at 2 of
3 voters. A member is started now when it has a name and client URLs,
which etcd publishes when the member runs.
The job "mesh / trixie" of keel#200 failed on
test_a_client_without_tls_does_not_stop_the_listener: the TLS
handshake of the second connection got EOF. A connection whose
handshake fails closes, and only then frees the slot of its source; the
client sees the close, asks again at once, and the listener closes the
new connection unread because the source still holds its slot.

The tests ask that the invite's listener and the members' channel free
the slot before they close a connection that failed.
keel#180 freed the slot before the answer leaves. A connection whose
handshake fails, or whose request cannot be read, never reaches the
handler, and serve_one freed its slot only after the close. The invite's
listener and the members' channel now free it first, also on that
path.
The coordinator's decision of 2026-10-10 on keel#140: a last handshake
older than 180 s is drift and means the member is unreachable only when
each peer sends a keepalive, and a keepalive keeps the NAT and firewall
state open between sites.

- keel.network.wireguard renders PersistentKeepalive = 25 for every peer
  whose spec gives none (DEFAULT_KEEPALIVE, keepalive()).
- keel spec apply sets it live with wg set. A change that only sets the
  keepalive of a peer the interface holds cannot cut the node off, as
  an addition cannot (keel#117), so keel mesh keeps it with no
  handshake and the first sync after the upgrade waits for nothing.
- keel diff takes 25 as the declared keepalive of a peer that gives
  none: a file written before is drift until apply writes it again.
- docs/spec.md, docs/diff.md, docs/apply.md.

Tests: the render, the default in keel diff (same, and drift for a file
without the line), the keepalive-only change kept as safe; the mesh
netns suites pass with it.

Rebased on keel 0.23.40 on 2026-10-16: the release test of LNMP 19.0-3 found the gap again. The BR2 host filters unsolicited inbound UDP, and after 290 s with no traffic the root holder could not send the cluster to the member on BR2 at the third join (keel#199). A keepalive from each peer keeps that state open.
@marcos-mendez
marcos-mendez merged commit d2c58d2 into main Oct 16, 2026
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