From e976bec05fb6be9d51115bce52972f733bb0c10a Mon Sep 17 00:00:00 2001 From: Rajan Dhabalia Date: Tue, 21 Jun 2022 15:59:05 -0700 Subject: [PATCH] Support mechanism to provide external zookeeper-server list to build global/configuration zookeeper (#15987) --- .../scripts/generate-zookeeper-config.sh | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/docker/pulsar/scripts/generate-zookeeper-config.sh b/docker/pulsar/scripts/generate-zookeeper-config.sh index 53d7600f80e1d..2852742ef2657 100755 --- a/docker/pulsar/scripts/generate-zookeeper-config.sh +++ b/docker/pulsar/scripts/generate-zookeeper-config.sh @@ -34,14 +34,22 @@ DOMAIN=`hostname -d` IDX=1 for SERVER in $(echo $ZOOKEEPER_SERVERS | tr "," "\n") do - echo "server.$IDX=$SERVER.$DOMAIN:2888:3888" >> $CONF_FILE - - if [ "$HOSTNAME" == "$SERVER" ]; then - MY_ID=$IDX - echo "Current server id $MY_ID" + if [[ ! -z "$EXTERNAL_PROVIDED_SERVERS" && $(fgrep -ix $EXTERNAL_PROVIDED_SERVERS <<< "true") ]]; then + echo "server.$IDX=$SERVER" >> $CONF_FILE + # external zk-server connect string starts with hostname + if [[ "$SERVER" == "$HOSTNAME"* ]]; then + MY_ID=$IDX + echo "Current server id $MY_ID" + fi + else + echo "server.$IDX=$SERVER.$DOMAIN:2888:3888" >> $CONF_FILE + if [ "$HOSTNAME" == "$SERVER" ]; then + MY_ID=$IDX + echo "Current server id $MY_ID" + fi fi - ((IDX++)) + ((IDX++)) done # For ZooKeeper container we need to initialize the ZK id