From d9ec643e86b84f1796df7cc759ad2f28c6058920 Mon Sep 17 00:00:00 2001 From: Michele Rastelli Date: Wed, 28 Aug 2024 10:57:31 +0200 Subject: [PATCH] CI: retry docker containers startup to work around CircleCI port mapping errors --- .circleci/config.yml | 8 ++++---- docker/start_db.sh | 8 ++++---- docker/start_kafka_zk.sh | 8 ++++---- docker/start_schema_registry.sh | 2 +- docker/startup_retry.sh | 18 ++++++++++++++++++ .../spi/ClusterKafkaConnectDeployment.java | 2 +- 6 files changed, 32 insertions(+), 14 deletions(-) create mode 100755 docker/startup_retry.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index bf053c8..c84a561 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,7 +85,7 @@ jobs: - load_cache - run: name: Create Kafka Environment - command: ./docker/startup.sh + command: ./docker/startup_retry.sh - run: name: Integration Tests command: mvn integration-test @@ -122,7 +122,7 @@ jobs: command: mvn package -Ddistributed - run: name: Create Kafka Environment - command: ./docker/startup.sh + command: ./docker/startup_retry.sh - run: name: Integration Tests command: mvn integration-test -Ddistributed -Darango.topology=$STARTER_MODE @@ -149,7 +149,7 @@ jobs: command: mvn package -Ddistributed - run: name: Create Kafka Environment - command: ./docker/startup.sh + command: ./docker/startup_retry.sh - run: name: Integration Tests command: mvn integration-test -Ddistributed -DSslTest=true -Dit.test=com.arangodb.kafka.SslIT @@ -173,7 +173,7 @@ jobs: - load_cache - run: name: Create Kafka Environment - command: ./docker/startup.sh + command: ./docker/startup_retry.sh - run: name: Start Toxiproxy command: ./bin/startProxy.sh diff --git a/docker/start_db.sh b/docker/start_db.sh index a20b895..058b108 100755 --- a/docker/start_db.sh +++ b/docker/start_db.sh @@ -55,14 +55,14 @@ if [ "$EXTENDED_NAMES" == "true" ]; then fi # data volume -docker create -v /data --name arangodb-data alpine:3 /bin/true -docker cp "$LOCATION"/jwtSecret arangodb-data:/data -docker cp "$LOCATION"/server.pem arangodb-data:/data +docker create -v /data --name adb-data alpine:3 /bin/true +docker cp "$LOCATION"/jwtSecret adb-data:/data +docker cp "$LOCATION"/server.pem adb-data:/data docker run -d \ --name=adb \ -p 8528:8528 \ - --volumes-from arangodb-data \ + --volumes-from adb-data \ -v /var/run/docker.sock:/var/run/docker.sock \ -e ARANGO_LICENSE_KEY="$ARANGO_LICENSE_KEY" \ $STARTER_DOCKER_IMAGE \ diff --git a/docker/start_kafka_zk.sh b/docker/start_kafka_zk.sh index 2053913..88b433d 100755 --- a/docker/start_kafka_zk.sh +++ b/docker/start_kafka_zk.sh @@ -11,7 +11,7 @@ ZK_DOCKER_IMAGE=docker.io/bitnami/zookeeper:3.8 docker pull $ZK_DOCKER_IMAGE docker run -d \ - --name zk-1 -h zk-1 \ + --name kafka-zk-1 -h kafka-zk-1 \ --network arangodb \ -e BITNAMI_DEBUG=true \ -e ALLOW_ANONYMOUS_LOGIN="yes" \ @@ -22,7 +22,7 @@ docker run -d \ --network arangodb \ -p 19092:19092 \ -e BITNAMI_DEBUG=true \ - -e KAFKA_CFG_ZOOKEEPER_CONNECT=zk-1 \ + -e KAFKA_CFG_ZOOKEEPER_CONNECT=kafka-zk-1 \ -e ALLOW_PLAINTEXT_LISTENER="yes" \ -e KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,PLAINTEXT_HOST://0.0.0.0:19092 \ -e KAFKA_CFG_ADVERTISED_LISTENERS="PLAINTEXT://kafka-1:9092,PLAINTEXT_HOST://172.28.0.1:19092" \ @@ -35,7 +35,7 @@ docker run -d \ --network arangodb \ -p 29092:29092 \ -e BITNAMI_DEBUG=true \ - -e KAFKA_CFG_ZOOKEEPER_CONNECT=zk-1 \ + -e KAFKA_CFG_ZOOKEEPER_CONNECT=kafka-zk-1 \ -e ALLOW_PLAINTEXT_LISTENER="yes" \ -e KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,PLAINTEXT_HOST://0.0.0.0:29092 \ -e KAFKA_CFG_ADVERTISED_LISTENERS="PLAINTEXT://kafka-2:9092,PLAINTEXT_HOST://172.28.0.1:29092" \ @@ -48,7 +48,7 @@ docker run -d \ --network arangodb \ -p 39092:39092 \ -e BITNAMI_DEBUG=true \ - -e KAFKA_CFG_ZOOKEEPER_CONNECT=zk-1 \ + -e KAFKA_CFG_ZOOKEEPER_CONNECT=kafka-zk-1 \ -e ALLOW_PLAINTEXT_LISTENER="yes" \ -e KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,PLAINTEXT_HOST://0.0.0.0:39092 \ -e KAFKA_CFG_ADVERTISED_LISTENERS="PLAINTEXT://kafka-3:9092,PLAINTEXT_HOST://172.28.0.1:39092" \ diff --git a/docker/start_schema_registry.sh b/docker/start_schema_registry.sh index 6e05e09..0fb3d51 100755 --- a/docker/start_schema_registry.sh +++ b/docker/start_schema_registry.sh @@ -6,7 +6,7 @@ docker pull $DOCKER_IMAGE KAFKA_BOOTSTRAP_SERVERS=PLAINTEXT://kafka-1:9092,PLAINTEXT://kafka-2:9092,PLAINTEXT://kafka-3:9092 docker run -d \ - --name schema-registry -h schema-registry \ + --name kafka-schema-registry -h kafka-schema-registry \ --network arangodb \ -p 8081:8081 \ -e SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS="$KAFKA_BOOTSTRAP_SERVERS" \ diff --git a/docker/startup_retry.sh b/docker/startup_retry.sh new file mode 100755 index 0000000..1fc54d2 --- /dev/null +++ b/docker/startup_retry.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# exit when any command fails +set -e + +until ./docker/startup.sh +do + # rm all containers, in case of retries + # retries might be needed in case of port-mapping errors in CircleCI, e.g. for errors like: + # docker: Error response from daemon: driver failed programming external connectivity on endpoint kafka-3: + # Error starting userland proxy: listen tcp4 0.0.0.0:39092: bind: address already in use. + + docker ps -a -f name=kafka-.* -q | while read x ; do docker rm -f $x ; done + docker rm -f adb + docker ps -a -f name=adb-.* -q | while read x ; do docker rm -f $x ; done + echo "Startup failed, retrying in 10 seconds..." + sleep 10 +done diff --git a/src/connect-distributed/java/spi/ClusterKafkaConnectDeployment.java b/src/connect-distributed/java/spi/ClusterKafkaConnectDeployment.java index f5680b4..ce42f24 100644 --- a/src/connect-distributed/java/spi/ClusterKafkaConnectDeployment.java +++ b/src/connect-distributed/java/spi/ClusterKafkaConnectDeployment.java @@ -57,7 +57,7 @@ public KafkaConnectOperations client() { @Override public String getSchemaRegistryUrlConnect() { - return "http://schema-registry:8081"; + return "http://kafka-schema-registry:8081"; } @Override