Skip to content

Add Zookeeper protocol checker with connection string support#10

Merged
alanthssss merged 2 commits into
mainfrom
copilot/connect-zookeeper
Mar 31, 2026
Merged

Add Zookeeper protocol checker with connection string support#10
alanthssss merged 2 commits into
mainfrom
copilot/connect-zookeeper

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Pulse only did generic TCP checks for all services, including Zookeeper. This adds a proper Zookeeper-aware checker using the four-letter word (FLW) ruok/imok protocol, and supports the standard Zookeeper ensemble connection string format.

Changes

checker/zookeeper.go

  • CheckZookeeperConnection(connectString, timeout) — parses a standard Zookeeper connection string (host1:2181,host2:2181,host3:2181[/chroot]) and returns nil if any node responds imok to ruok
  • Falls back gracefully: a plain host:port is treated as a single-node connection string
  • On total failure, reports all per-node errors for diagnostics

main.go

  • Dispatches to CheckZookeeperConnection when service == "zookeeper"; all other services continue using the generic TCP checker

config.yml

  • Zookeeper entries consolidated into ensemble connection string format:
zookeeper:
  - 10.0.1.27:2181,10.0.1.28:2181,10.0.1.29:2181

checker/zookeeper_test.go

  • Tests for: successful handshake, unexpected response, connection refused, single host, partial ensemble availability, chroot stripping, empty input, and connection string parsing

Copilot AI linked an issue Mar 31, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/keyscome/pulse/sessions/88baa49e-c12a-4f86-9603-50ccbcb03561

Co-authored-by: alanthssss <32271197+alanthssss@users.noreply.github.com>
Copilot AI changed the title [WIP] Connect Zookeeper with connection string Add Zookeeper protocol checker with connection string support Mar 31, 2026
Copilot AI requested a review from alanthssss March 31, 2026 16:14
@alanthssss
Copy link
Copy Markdown
Member

@copilot
if we need remain the tcp network check? or just delete the old way
i want to know the best practce

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot
if we need remain the tcp network check? or just delete the old way
i want to know the best practce

The generic TCP CheckConnection is intentionally kept — it's still used for every other service (Redis, Kafka, Elasticsearch, etc.). For Zookeeper specifically, the ruok/imok check replaces it rather than running in addition to it, because:

  1. ruok already implies TCP reachabilitycheckZookeeperNode does net.DialTimeout first, so a failed TCP connection is still caught and reported as an error.
  2. More meaningful signal — a port can be open (TCP succeeds) while Zookeeper itself is in an error state; ruok/imok verifies the process is actually healthy, not just listening.
  3. No redundancy needed — running a plain TCP check and a ruok check on the same address would just report the same failure twice with different messages.

One caveat: Zookeeper ≥ 3.5 requires ruok to be explicitly whitelisted (4lw.commands.whitelist=ruok in zoo.cfg). If your deployment restricts four-letter words, the Zookeeper-specific checker will fail even when the node is healthy. In that case, falling back to the plain TCP check in checker.go for that service is the right call.

@alanthssss alanthssss marked this pull request as ready for review March 31, 2026 16:39
Copy link
Copy Markdown
Member

@alanthssss alanthssss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alanthssss alanthssss merged commit ac867d0 into main Mar 31, 2026
1 check passed
@alanthssss alanthssss deleted the copilot/connect-zookeeper branch March 31, 2026 16:40
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.

Connect Zookeeper

2 participants