Skip to content

Commit

Permalink
Use docker compose exec to create additional kafka topics
Browse files Browse the repository at this point in the history
  • Loading branch information
saz committed Mar 27, 2024
1 parent c4ae491 commit ccec185
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions install/create-kafka-topics.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
echo "${_group}Creating additional Kafka topics ..."

# NOTE: This step relies on `kafka` being available from the previous `snuba-api bootstrap` step
$dc up --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 ccec185

Please sign in to comment.