Skip to content

Commit e4adaba

Browse files
committed
Use docker compose exec to create additional kafka topics
1 parent 437bddd commit e4adaba

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

install/create-kafka-topics.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
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 --no-build --no-recreate kafka
4+
5+
while [ true ]
6+
do
7+
$kafka_healthy=$(docker compose ps kafka | grep 'healthy')
8+
if [ ! -z "$kafka_healthy" ]; then
9+
break
10+
fi
11+
12+
echo "Kafka container is not healthy, waiting for 30 seconds. If this took too long, abort the installation process, and check your Kafka configuration"
13+
sleep 30s
14+
done
15+
416
# 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)
17+
EXISTING_KAFKA_TOPICS=$($dc exec -T kafka kafka-topics --list --bootstrap-server kafka:9092 2>/dev/null)
618
NEEDED_KAFKA_TOPICS="ingest-attachments ingest-transactions ingest-events ingest-replay-recordings profiles ingest-occurrences ingest-metrics ingest-performance-metrics ingest-monitors"
719
for topic in $NEEDED_KAFKA_TOPICS; do
820
if ! echo "$EXISTING_KAFKA_TOPICS" | grep -qE "(^| )$topic( |$)"; then
9-
$dcr kafka kafka-topics --create --topic $topic --bootstrap-server kafka:9092
21+
$dc exec kafka kafka-topics --create --topic $topic --bootstrap-server kafka:9092
1022
echo ""
1123
fi
1224
done

0 commit comments

Comments
 (0)