Skip to content

Commit

Permalink
Use getent instead of nslookup for starting scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Jin Huang <[email protected]>
  • Loading branch information
Jin Huang authored and jinfwhuang committed Aug 19, 2021
1 parent c62716b commit a454656
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docker/bin/zookeeperFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function zkConfig() {
function zkConnectionString() {
# If the client service address is not yet available, then return localhost
set +e
nslookup "${CLIENT_HOST}" 2>/dev/null 1>/dev/null
if [[ $? -eq 1 ]]; then
getent hosts "${CLIENT_HOST}" 2>/dev/null 1>/dev/null
if [[ $? -ne 0 ]]; then
set -e
echo "localhost:${CLIENT_PORT}"
else
Expand Down
4 changes: 2 additions & 2 deletions docker/bin/zookeeperReady.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ OK=$(echo ruok | nc 127.0.0.1 $CLIENT_PORT)
# Check to see if zookeeper service answers
if [[ "$OK" == "imok" ]]; then
set +e
nslookup $DOMAIN
if [[ $? -eq 1 ]]; then
getent hosts $DOMAIN
if [[ $? -ne 0 ]]; then
set -e
echo "There is no active ensemble, skipping readiness probe..."
exit 0
Expand Down
6 changes: 3 additions & 3 deletions docker/bin/zookeeperStart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ if [[ -n "$ENVOY_SIDECAR_STATUS" ]]; then
fi
set -e

# Determine if there is a ensemble available to join by checking the service domain
# Determine if there is an ensemble available to join by checking the service domain
set +e
nslookup $DOMAIN
getent hosts $DOMAIN # This only performs a dns lookup
if [[ $? -eq 0 ]]; then
ACTIVE_ENSEMBLE=true
elif nslookup $DOMAIN | grep -q "server can't find $DOMAIN"; then
Expand All @@ -87,7 +87,7 @@ else
do
sleep 2
((count=count-1))
nslookup $DOMAIN
getent hosts $DOMAIN
if [[ $? -eq 0 ]]; then
ACTIVE_ENSEMBLE=true
break
Expand Down

0 comments on commit a454656

Please sign in to comment.