Skip to content

Commit d586cff

Browse files
authored
Use docker compose exec to create additional kafka topics (#2904)
1 parent 9228299 commit d586cff

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

install/create-kafka-topics.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
echo "${_group}Creating additional Kafka topics ..."
22

3-
# NOTE: This step relies on `kafka` being available from the previous `snuba-api bootstrap` step
3+
$dc up -d --no-build --no-recreate kafka
4+
5+
while [ true ]; do
6+
kafka_healthy=$($dc ps kafka | grep 'healthy')
7+
if [ ! -z "$kafka_healthy" ]; then
8+
break
9+
fi
10+
11+
echo "Kafka container is not healthy, waiting for 30 seconds. If this took too long, abort the installation process, and check your Kafka configuration"
12+
sleep 30s
13+
done
14+
415
# XXX(BYK): We cannot use auto.create.topics as Confluence and Apache hates it now (and makes it very hard to enable)
5-
EXISTING_KAFKA_TOPICS=$($dcr -T kafka kafka-topics --list --bootstrap-server kafka:9092 2>/dev/null)
16+
EXISTING_KAFKA_TOPICS=$($dc exec -T kafka kafka-topics --list --bootstrap-server kafka:9092 2>/dev/null)
617
NEEDED_KAFKA_TOPICS="ingest-attachments ingest-transactions ingest-events ingest-replay-recordings profiles ingest-occurrences ingest-metrics ingest-performance-metrics ingest-monitors"
718
for topic in $NEEDED_KAFKA_TOPICS; do
819
if ! echo "$EXISTING_KAFKA_TOPICS" | grep -qE "(^| )$topic( |$)"; then
9-
$dcr kafka kafka-topics --create --topic $topic --bootstrap-server kafka:9092
20+
$dc exec kafka kafka-topics --create --topic $topic --bootstrap-server kafka:9092
1021
echo ""
1122
fi
1223
done

0 commit comments

Comments
 (0)