Skip to content

Commit

Permalink
Use docker compose exec to create additional kafka topics (#2904)
Browse files Browse the repository at this point in the history
  • Loading branch information
saz authored Apr 17, 2024
1 parent 9228299 commit d586cff
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions install/create-kafka-topics.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit d586cff

Please sign in to comment.