Skip to content

Commit

Permalink
Update diagnostic server to get IPs from metaserver instead (docker-a…
Browse files Browse the repository at this point in the history
…rchive#628)

Signed-off-by: Nathan LeClaire <[email protected]>
  • Loading branch information
nathanleclaire authored and FrenchBen committed Jan 13, 2017
1 parent 20b7399 commit ef9eb05
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions aws/dockerfiles/files/bin/docker-diagnose
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,20 @@ platform()
fi
}

node_hostnames()
{
docker node inspect $(docker node ls -q) | jq -r '.[] | .Description.Hostname'
}

azure_resolver()
{
# Sample /etc/resolv.conf on Azure:
#
# # Generated by dhcpcd from eth0.dhcp
# # /etc/resolv.conf.head can replace this line
# domain zopqyteo2tpuxc1cyzroivpijh.gx.internal.cloudapp.net
# nameserver 168.63.129.16
# # /etc/resolv.conf.tail can replace this line
#
cat /etc/resolv.conf | grep domain | awk '{ print $2; }'
}

if [ "$(platform)" = "aws" ]
then
NODES=$(node_hostnames)
# Get instance private IP from AWS metadata service if on AWS.
METASERVER_ADDR=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4/)
else
# We need to append to the hostnames with the DNS resolver address, or
# else they won't resolve properly.
#
# We could potentially modify swarm to accept a "hostname" (more
# properly nodename) type flag on join, but no such option seems
# available today.
NODES=$(node_hostnames | sed -e "s/$/.$(azure_resolver)/")
# Azure shell is run with --net host so use localhost.
METASERVER_ADDR=localhost
fi

NODES=$(curl -s "${METASERVER_ADDR}:9024/instances/all/")
if [ $? -ne 0 ]; then
>&2 echo "Sorry, there was an error getting IPs for the cluster."
>&2 echo "Are you invoking $0 from a manager node?"
exit 1
fi

# Session is set to a pseudo-random string combined with the current timestamp.
Expand Down

0 comments on commit ef9eb05

Please sign in to comment.