Skip to content

Manage etcd with lavinmqctl#1804

Draft
annieblomgren wants to merge 5 commits intomainfrom
manage-etcd-with-lavinmqctl
Draft

Manage etcd with lavinmqctl#1804
annieblomgren wants to merge 5 commits intomainfrom
manage-etcd-with-lavinmqctl

Conversation

@annieblomgren
Copy link
Copy Markdown
Contributor

@annieblomgren annieblomgren commented Mar 9, 2026

Related to #1350

Summary

  • Adds lavinmqctl list_in_sync_replicas command that queries etcd directly (no LavinMQ HTTP API required)
  • Outputs a table with node_id, address, and role (leader/follower) for each in-sync replica
  • Adds lavinmqctl list_etcd_members command that queries the etcd MemberList API directly
  • Outputs a table with name, peer_urls, client_urls, and learner status for each etcd member
  • Adds --etcd-endpoints and --etcd-prefix global options (also read from LAVINMQ_CLUSTERING_ETCD_ENDPOINTS / LAVINMQ_CLUSTERING_ETCD_PREFIX env vars)
  • Adds election_leader and member_list methods to Etcd class

How it works

Node addresses are discovered by calling get_prefix("{prefix}/leader/") — etcd stores each campaigning node's advertised URI under {prefix}/leader/{hex_lease_id}, where the hex lease ID converts to the base-36 node ID via hex.to_i64(16).to_s(36).

list_etcd_members calls /v3/cluster/member/list directly, giving operators visibility into the etcd layer that LavinMQ clustering depends on. Since etcd quorum loss means LavinMQ loses leader election and ISR tracking, this command helps with:

  • Verifying all expected etcd members have joined the cluster
  • Checking which client_urls to use for --clustering-etcd-endpoints
  • Spotting stuck learners that haven't been promoted to full voting members
  • Identifying when the cluster is at risk (e.g. a 3-node cluster down to 2 members is one failure away from losing quorum)

Test plan

  • Start a multi-node LavinMQ cluster with etcd
  • Run lavinmqctl --etcd-endpoints=<host:port> list_in_sync_replicas
  • Verify all in-sync nodes appear with correct addresses and roles
  • Run lavinmqctl --etcd-endpoints=<host:port> list_etcd_members
  • Verify all etcd members appear with correct names, peer/client URLs and learner status
  • Run against a single-instance LavinMQ and verify error message: "Is LavinMQ running in a cluster?"

🤖 Generated with Claude Code

annieblomgren and others added 4 commits March 9, 2026 11:42
Queries etcd directly to list nodes in the in-sync replica set, their
advertised addresses, and whether each node is leader or follower.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Handle empty etcd response in get_prefix (no kvs key)
- Show "unknown" role when no leader is elected
- Default --etcd-endpoints to localhost:2379
- Remove blank separator before version/help flags

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude bot commented Mar 9, 2026

No issues found.

Lists etcd cluster members using the MemberList API, showing name,
peer_urls, client_urls and learner status.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
✅ (annieblomgren)[https://github.com/annieblomgren]
@Loofeit
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@Loofeit
Copy link
Copy Markdown

Loofeit commented Mar 31, 2026

Added lavinmqctl list_etcd_members command

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.

2 participants