Fix run_docker_login DNS lookup to properly handle IPv6

It turns out that the nslookup tool doesn't handle IPv6 lookups by
default, at least the way our DNS server is configured.

In order to deal with this we switch to using the "dig" command, which
allows asking for both the A and AAAA records (IPv4 and IPv6,
respectively) in a single command.  A return code of 0 means we got
a response from the server, and if we did get a response then a
non-empty output  means that we successfully looked up the hostname.

Change-Id: I6efec9fe20ba192422ae19989430b1e8866f70dd
Partial-Bug: 1886121
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
This commit is contained in:
Chris Friesen 2020-07-06 17:33:15 -06:00
parent fb3840bbad
commit f5d8c40993
1 changed files with 12 additions and 3 deletions

View File

@ -21,11 +21,20 @@ function LOG {
LOG "Waiting for registry.local to resolve"
while true
do
nslookup registry.local &> /dev/null
# This will ask for both A and AAAA records to handle IPv4 and IPv6.
# We don't want to do an ANY request because some DNS servers reject
# them and they can return way more data than we actually want.
ADDR=`dig +short registry.local A registry.local AAAA`
if [ $? -eq 0 ]
then
LOG "registry.local resolved, continuing with docker login"
break
# We got a response back from the server, but we need to check
# if we got an address or not. If there is no address, ADDR will
# be an empty string.
if [ -n "$ADDR" ]
then
echo LOG "registry.local resolved, continuing with docker login"
break
fi
fi
sleep 1
done