Skip to content

fix(compose): probe Kafka via non-JVM ApiVersions wire check - #10

Merged
slayerjain merged 1 commit into
order_messagefrom
fix/kafka-healthcheck-non-jvm-next
Nov 23, 2026
Merged

slayerjain merged 1 commit into
order_messagefrom
fix/kafka-healthcheck-non-jvm-next

Conversation

@slayerjain

Copy link
Copy Markdown
Member

Why

In keploy/api-server Woodpecker pipeline 10651 (step 41, atg-with-mocks > regression), Phase 5 recreated orderflow-kafka (confluentinc/cp-kafka:7.4.0) on a fresh empty anonymous volume (Loaded 0 logs in 69ms), and the broker logged [KafkaServer id=1] started at 14:48:12 — 7 seconds after start — yet docker compose up -d --wait failed about 3 minutes later with container orderflow-kafka is unhealthy (Up 4 minutes (unhealthy)).

docker-compose.yml probes Kafka with kafka-broker-api-versions --bootstrap-server localhost:9092 (interval: 15s, timeout: 10s, retries: 10). Each healthcheck boots a fresh JVM to send one ApiVersions request. Under runner CPU contention, JVM startup alone exceeds the 10 s timeout, causing consecutive Health check exceeded timeout (10s) failures until Docker marks the running broker unhealthy. Fixing this in orderflow/docker-compose.yml covers all 8 Kafka bring-ups in atg-with-mocks, including the 5 keploy sandbox record/test steps that compose orderflow/docker-compose.yml alone.

Merge order: 1. merge this keploy/orderflow PR into order_message first; 2. merge the companion keploy/api-server PR (fix/regression-kafka-phase5-restart-next) into main second.

What

  • docker-compose.yml: replace services.kafka.healthcheck.test with a zero-JVM Kafka wire-protocol ApiVersions v0 (API key 18, version 0) probe over TCP using the container image's stdlib python3, verifying the returned correlation_id, error_code == 0, non-zero API version count, and exact frame length (10 + 6 * cnt) while keeping the existing interval: 15s, timeout: 10s, and retries: 10 bounds unchanged.
  • scripts/test_kafka_healthcheck.py: standalone Python unittest suite pinning the non-JVM probe and existing 15s/10s/10 bounds, and executing the exact healthcheck.test command parsed from docker-compose.yml against local TCP responders covering a valid ApiVersions v0 reply, a closed port, an HTTP non-Kafka server, a non-zero Kafka error_code, a mismatched correlation_id, an empty API versions list, and a truncated response frame.

Evidence

  • Sandbox bring-up (docker-compose.yml alone, no regression override) before vs after under identical CPU throttling (cpus: 0.09, existing 15s/10s/10 bounds, HEAD 02d01a2e0a1f6cda55d5541cf3ded0f71d30ed47 vs origin/order_message cb5403b27):
    • Unmodified origin/order_message (JVM kafka-broker-api-versions): Kafka started (Loaded 0 logs in 298ms, [KafkaServer id=1] started at 01:34:32Z), then docker compose up -d --wait exited 1 at 265 s (Status: unhealthy, FailingStreak: 10, repeated ExitCode: -1 "Health check exceeded timeout (10s)"). Direct JVM probe timings on the running throttled broker: 15,853 ms, 21,619 ms, 20,099 ms.
    • Pushed HEAD 02d01a2e0 (Python ApiVersions v0):
      • Sandbox bring-up Tweak order response fields #1: exited 0 in 75 s (Status: healthy, FailingStreak: 0; Docker's passing healthcheck probe took 403 ms, rejecting ConnectionRefusedError while Kafka was booting).
      • Direct non-JVM probe timings on the running throttled broker: 4 ms, 98 ms, 98 ms in-container (452 ms, 403 ms, 497 ms including docker exec).
      • Phase 5 recreate (docker rm -f + docker compose up -d --wait at cpus: 0.09): exited 0 in 75 s (Status: healthy, FailingStreak: 0; Docker's passing healthcheck probe took 497 ms).
  • Config, unit tests, and mutants on pushed HEAD 02d01a2e0a1f6cda55d5541cf3ded0f71d30ed47:
    • docker compose -f docker-compose.yml config: valid.
    • python3 -m unittest -v scripts/test_kafka_healthcheck.py: 8/8 tests passed in both KEPLOY_PROVEN unset and KEPLOY_PROVEN=1.
    • 4/4 mutants killed in both KEPLOY_PROVEN unset and KEPLOY_PROVEN=1: revert to kafka-broker-api-versions, weaken to true, ignore non-zero Kafka error_code, and weaken to a bare TCP create_connection().close() check.

kafka's healthcheck ran kafka-broker-api-versions, which boots a fresh
JVM on every probe and exceeds its 10 s timeout on CPU-loaded CI runners
even after Kafka logs '[KafkaServer id=1] started' (keploy/api-server
pipeline 10651, step 41).

Replace the healthcheck command in docker-compose.yml with a direct
Kafka wire-protocol ApiVersions v0 request using the image's stdlib
python3 (zero JVM startup), verifying correlation_id, error_code == 0,
non-zero API version count, and exact frame length within the existing
interval/timeout/retries bounds (15s/10s/10).

Add scripts/test_kafka_healthcheck.py to pin the non-JVM probe and
bounds and test the exact YAML command against valid and invalid local
TCP responders.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@slayerjain
slayerjain merged commit 60f6ee1 into order_message Nov 23, 2026
1 check 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.

1 participant