Skip to content

Commit

Permalink
fix the kafka container's health check (#27905) (#27916)
Browse files Browse the repository at this point in the history
(cherry picked from commit b99361f)

Co-authored-by: Fae Charlton <[email protected]>
  • Loading branch information
mergify[bot] and faec authored Sep 14, 2021
1 parent fe58408 commit 4ac4258
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions testing/environments/docker/kafka/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ ADD healthcheck.sh /healthcheck.sh
EXPOSE 9092
EXPOSE 2181

# Healthcheck creates an empty topic foo. As soon as a topic is created, it assumes broke is available
HEALTHCHECK --interval=1s --retries=600 CMD /healthcheck.sh
# healthcheck.sh tries to create and delete an empty kafka topic (the topic
# string is based on the timestamp), and reports healthy if topic creation
# was successful.
# With these parameters, Docker will consider the container unhealthy if the
# Kafka server is unresponsive for 3 minutes.
HEALTHCHECK --start-period=10s --interval=5s --timeout=5s --retries=36 CMD /healthcheck.sh

ENTRYPOINT ["/run.sh"]
2 changes: 1 addition & 1 deletion testing/environments/docker/kafka/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ if [[ $rc != 0 ]]; then
exit $rc
fi

${KAFKA_HOME}/bin/kafka-topic.sh --zookeeper=127.0.0.1:2181 --delete --topic "${TOPIC}"
${KAFKA_HOME}/bin/kafka-topics.sh --zookeeper=127.0.0.1:2181 --delete --topic "${TOPIC}"
exit 0

0 comments on commit 4ac4258

Please sign in to comment.