Skip to content

Commit

Permalink
Adding SEED_PORT to have a port override alongside the existing SEED_…
Browse files Browse the repository at this point in the history
…NODE. (#31)

* adding SEED_PORT as a potential override to clientport for zookeeper management scripts

* Make zu.jar run over ssl

* updating zookeeperStart.sh

* taking out debug echo's and fixing zookeeper readyness check to have ssl_options if 2182 is used

* removing debug echos

---------

Co-authored-by: Cameron Wright <[email protected]>
Co-authored-by: Razvan Dobre <[email protected]>
  • Loading branch information
3 people committed Aug 14, 2024
1 parent b5af315 commit 5f2fec6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
7 changes: 6 additions & 1 deletion docker/bin/zookeeperFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ function zkConnectionString() {
set -e
echo "localhost:${CLIENT_PORT}"
else
if [ -z "${SEED_PORT}" ]; then
PORT=${CLIENT_PORT}
else
PORT=${SEED_PORT}
fi
set -e
echo "${CLIENT_HOST}:${CLIENT_PORT}"
echo "${CLIENT_HOST}:${PORT}"
fi
}
13 changes: 9 additions & 4 deletions docker/bin/zookeeperReady.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ OFFSET=${OFFSET:-1}
# CLIENT_HOST is used in zkConnectionString function already to create zkURL
CLIENT_HOST=${SEED_NODE:-$CLIENT_HOST}


OK=$(echo ruok | socat stdio tcp:localhost:$CLIENT_PORT)

# Check to see if zookeeper service answers
Expand Down Expand Up @@ -88,12 +87,18 @@ if [[ "$OK" == "imok" ]]; then
exit 0
elif [[ "$ROLE" == "observer" ]]; then
echo "Zookeeper service is ready to be upgraded from observer to participant."
ROLE=participant
SSL_OPTIONS="-Dzookeeper.clientCnxnSocket=org.apache.zookeeper.ClientCnxnSocketNetty -Dzookeeper.client.secure=true"
ZKURL=$(zkConnectionString)
ROLE=participant
ZKCONFIG=$(zkConfig $OUTSIDE_NAME)
java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar remove $ZKURL $MYID
if [[ "$ZKURL" =~ :2182$ ]]; then
ZK_OPTIONS="$SSL_OPTIONS"
else
ZK_OPTIONS=""
fi
java -Dlog4j.configuration=file:"$LOG4J_CONF" $ZK_OPTIONS -jar /opt/libs/zu.jar remove $ZKURL $MYID
sleep 1
java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG
java -Dlog4j.configuration=file:"$LOG4J_CONF" $ZK_OPTIONS -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG
exit 0
else
echo "Something has gone wrong. Unable to determine zookeeper role."
Expand Down
12 changes: 10 additions & 2 deletions docker/bin/zookeeperStart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if [ -f $MYID_FILE ]; then
fi
fi

if [ -f $DYNCONFIG ]; then
if [ -f $DYNCONFIG ] && [ -z $SEED_NODE ]; then
ONDISK_DYN_CONFIG=true
fi

Expand Down Expand Up @@ -137,6 +137,7 @@ else
fi
fi


if [[ "$WRITE_CONFIGURATION" == true ]]; then
echo "Writing myid: $MYID to: $MYID_FILE."
echo $MYID > $MYID_FILE
Expand All @@ -151,13 +152,20 @@ if [[ "$WRITE_CONFIGURATION" == true ]]; then
fi
fi


if [[ "$REGISTER_NODE" == true ]]; then
ROLE=observer
ZKURL=$(zkConnectionString)
ZKCONFIG=$(zkConfig $OUTSIDE_NAME)
set -e
echo Registering node and writing local configuration to disk.
java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG $DYNCONFIG
SSL_OPTIONS="-Dzookeeper.clientCnxnSocket=org.apache.zookeeper.ClientCnxnSocketNetty -Dzookeeper.client.secure=true"
if [[ "$ZKURL" =~ :2182$ ]]; then
ZK_OPTIONS="$SSL_OPTIONS"
else
ZK_OPTIONS=""
fi
java -Dlog4j.configuration=file:"$LOG4J_CONF" $ZK_OPTIONS -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG $DYNCONFIG
set +e
fi

Expand Down
3 changes: 3 additions & 0 deletions docker/zu/src/main/java/io/pravega/zookeeper/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fun runSync(args: Array<String>, suppressOutput: Boolean = false): String {
if (! suppressOutput) {
print(clusterSize)
}
zk.close()
clusterSize
} catch (e: Exception) {
System.err.println("Error performing zookeeper sync operation:")
Expand All @@ -71,6 +72,7 @@ fun runGetAll(args: Array<String>, suppressOutput: Boolean = false): String {
if (! suppressOutput) {
print(zkCfg)
}
zk.close()
zkCfg
} catch (e: Exception) {
System.err.println("Error getting server config")
Expand Down Expand Up @@ -129,6 +131,7 @@ fun reconfigure(zkUrl: String, joining: String?, leaving: String?, outputFile: S
} else {
File(outputFile).bufferedWriter().use {it.write(cfgStr + "\n")}
}
zk.close()
} catch (e: Exception) {
System.err.println("Error performing zookeeper reconfiguration:")
e.printStackTrace(System.err)
Expand Down

0 comments on commit 5f2fec6

Please sign in to comment.