Skip to content

Commit 4cb7cc5

Browse files
jinfwhuangJin Huang
authored andcommitted
Use getent instead of nslookup for starting scripts (#5)
* Use getent instead of nslookup for starting scripts * update zk image * use default image Co-authored-by: Jin Huang <[email protected]>
1 parent 3874436 commit 4cb7cc5

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

docker/bin/zookeeperFunctions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function zkConfig() {
1919
function zkConnectionString() {
2020
# If the client service address is not yet available, then return localhost
2121
set +e
22-
nslookup "${CLIENT_HOST}" 2>/dev/null 1>/dev/null
23-
if [[ $? -eq 1 ]]; then
22+
getent hosts "${CLIENT_HOST}" 2>/dev/null 1>/dev/null
23+
if [[ $? -ne 0 ]]; then
2424
set -e
2525
echo "localhost:${CLIENT_PORT}"
2626
else

docker/bin/zookeeperReady.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ OK=$(echo ruok | nc 127.0.0.1 $CLIENT_PORT)
2525
# Check to see if zookeeper service answers
2626
if [[ "$OK" == "imok" ]]; then
2727
set +e
28-
nslookup $DOMAIN
29-
if [[ $? -eq 1 ]]; then
28+
getent hosts $DOMAIN
29+
if [[ $? -ne 0 ]]; then
3030
set -e
3131
echo "There is no active ensemble, skipping readiness probe..."
3232
exit 0

docker/bin/zookeeperStart.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ if [[ -n "$ENVOY_SIDECAR_STATUS" ]]; then
6969
fi
7070
set -e
7171

72-
# Determine if there is a ensemble available to join by checking the service domain
72+
# Determine if there is an ensemble available to join by checking the service domain
7373
set +e
74-
nslookup $DOMAIN
75-
if [[ $? -eq 1 ]]; then
76-
# If an nslookup of the headless service domain fails, then there is no
77-
# active ensemble yet, but in certain cases nslookup of headless service
74+
getent hosts $DOMAIN # This only performs a dns lookup
75+
if [[ $? -ne 0 ]]; then
76+
# If dns lookup of the headless service domain fails, then there is no
77+
# active ensemble yet, but in certain cases the dns lookup of headless service
7878
# takes a while to come up even if there is active ensemble
7979
ACTIVE_ENSEMBLE=false
8080
declare -i count=20
8181
while [[ $count -ge 0 && $MYID -ne 1 ]]
8282
do
8383
sleep 2
8484
((count=count-1))
85-
nslookup $DOMAIN
85+
getent hosts $DOMAIN
8686
if [[ $? -eq 0 ]]; then
8787
ACTIVE_ENSEMBLE=true
8888
break

0 commit comments

Comments
 (0)