Skip to content

kafka-mesh: Add healthchecks for the Kafka brokers - #1701

Merged
phlax merged 1 commit into
envoyproxy:mainfrom
phlax:fix-hc-kafka-mesh
Nov 29, 2026
Merged

phlax merged 1 commit into
envoyproxy:mainfrom
phlax:fix-hc-kafka-mesh

Conversation

@phlax

@phlax phlax commented Nov 29, 2026

Copy link
Copy Markdown
Member

Nothing waited for the Kafka brokers in kafka-mesh, so the first produce through the proxy was retried until they were up (verify.sh:17). In the stress job that took up to 48s, of a wait that gives up after 30 attempts, each of which starts a JVM.

This gives both brokers a healthcheck and has the proxy wait for them, so docker compose up --wait returns when they can be used.

A broker's port is open well before it will answer anything, so a port check passes too early, and asking with the Kafka tools means starting a JVM for every check, which is a lot to run every couple of seconds in a container that is busy starting. The check instead sends the smallest request there is, for the API versions the broker supports, from bash, and passes once there is a reply.

The retry of the first produce is kept: it is also what creates the topic. With the containers limited to 0.25 CPU locally it passed on its first attempt, in 11s.

Tested locally, and again with all of the example's containers limited to 0.25 CPU.

This touches kafka-mesh/docker-compose.yaml and verify.sh, as does #1672, so whichever lands second will need rebasing.

Nothing waited for the brokers, so the first produce through the proxy
was retried until they were up. In the stress job it took up to 48s
that way, of a wait that gives up after 30 attempts.

Give the brokers a healthcheck, and have the proxy wait for them. A
broker is listening well before it will answer, and asking with the
Kafka tools starts a JVM each time, so the check sends a minimal API
versions request and passes once the broker replies.

The retry of the first produce is kept, as that is also what creates
the topic.

Signed-off-by: Ryan Northey <ryan@synca.io>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the broker healthchecks and proxy startup dependencies.

No open issues 🎉

What changed in this PR

This PR improves startup readiness in the Kafka mesh sandbox by waiting for both brokers to respond before starting the proxy.

Changes:

  • Adds a shared, lightweight Kafka API-versions healthcheck to both brokers and makes the proxy depend on their healthy status.
  • Clarifies why the first produce operation still retries during topic creation; verification behavior is unchanged.
File Description
kafka-mesh/​verify.sh Updates the comment explaining the retained first-produce retry.
kafka-mesh/​docker-compose.yaml Adds broker healthchecks and proxy readiness dependencies.

Review effort: Balanced

@phlax
phlax marked this pull request as ready for review November 29, 2026 22:30
@phlax
phlax merged commit f055235 into envoyproxy:main Nov 29, 2026
8 checks passed
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