Fix run_docker_login DNS lookup to handle misconfigured nameservers
A customer added a non-existant nameserver and it resulted in an edge case that broke the previous code. (dig returned 9 even though it found an AAAA record for the name.) It looks like we're going to need to bite the bullet and explicitly issue separate requests for IPv4 and IPv6. Partial-Bug: 1886121 Change-Id: I8d653a82a2aee0a86af587f6392277974c9f1fef Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
This commit is contained in:
parent
63d97f96da
commit
133eb1d450
|
@ -21,10 +21,14 @@ function LOG {
|
|||
LOG "Waiting for registry.local to resolve"
|
||||
while true
|
||||
do
|
||||
# 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`
|
||||
# We can't easily ask for both A and AAAA records in the same request
|
||||
# because if the customer mis-configures things with a "good" nameserver
|
||||
# and a non-existant nameserver dig will return "9" even though it finds
|
||||
# an AAAA record on the "good" server. So we need to ask for A and AAAA
|
||||
# records separately. Once we have either type of record we can proceed.
|
||||
|
||||
# First check for A records for IPv4
|
||||
ADDR=`dig +short registry.local A`
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
# We got a response back from the server, but we need to check
|
||||
|
@ -32,10 +36,25 @@ do
|
|||
# be an empty string.
|
||||
if [ -n "$ADDR" ]
|
||||
then
|
||||
echo LOG "registry.local resolved, continuing with docker login"
|
||||
echo LOG "registry.local resolved IPv4, continuing with docker login"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
# Then check for AAAA records for IPv6
|
||||
ADDR=`dig +short registry.local AAAA`
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
# 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 IPv6, continuing with docker login"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in New Issue