From d586cff03af2acfe01775ee91b3c0365bac20d53 Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Wed, 17 Apr 2024 18:38:21 +0200 Subject: [PATCH] Use docker compose exec to create additional kafka topics (#2904) --- install/create-kafka-topics.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/install/create-kafka-topics.sh b/install/create-kafka-topics.sh index 7f9022e393..63e0cffa01 100644 --- a/install/create-kafka-topics.sh +++ b/install/create-kafka-topics.sh @@ -1,12 +1,23 @@ echo "${_group}Creating additional Kafka topics ..." -# NOTE: This step relies on `kafka` being available from the previous `snuba-api bootstrap` step +$dc up -d --no-build --no-recreate kafka + +while [ true ]; do + kafka_healthy=$($dc ps kafka | grep 'healthy') + if [ ! -z "$kafka_healthy" ]; then + break + fi + + echo "Kafka container is not healthy, waiting for 30 seconds. If this took too long, abort the installation process, and check your Kafka configuration" + sleep 30s +done + # XXX(BYK): We cannot use auto.create.topics as Confluence and Apache hates it now (and makes it very hard to enable) -EXISTING_KAFKA_TOPICS=$($dcr -T kafka kafka-topics --list --bootstrap-server kafka:9092 2>/dev/null) +EXISTING_KAFKA_TOPICS=$($dc exec -T kafka kafka-topics --list --bootstrap-server kafka:9092 2>/dev/null) NEEDED_KAFKA_TOPICS="ingest-attachments ingest-transactions ingest-events ingest-replay-recordings profiles ingest-occurrences ingest-metrics ingest-performance-metrics ingest-monitors" for topic in $NEEDED_KAFKA_TOPICS; do if ! echo "$EXISTING_KAFKA_TOPICS" | grep -qE "(^| )$topic( |$)"; then - $dcr kafka kafka-topics --create --topic $topic --bootstrap-server kafka:9092 + $dc exec kafka kafka-topics --create --topic $topic --bootstrap-server kafka:9092 echo "" fi done