correctly check whether weavedns is running
and return an error status rather than exit when containers stop just before an HTTP call, which in turn allows us to make tell_dns properly ignore weavedns container absences. Fixes #300
This commit is contained in:
1 parent
d7405bf8d5
commit
a0ec8c4daa
1 file changed
+5
-5
@@ -277,19 +277,19 @@ detach() {
|
|||||||
http_call() {
|
http_call() {
|
||||||
if ! status=$(docker inspect --format='{{ .State.Running }} {{ .NetworkSettings.IPAddress }}' $1 2>/dev/null); then
|
if ! status=$(docker inspect --format='{{ .State.Running }} {{ .NetworkSettings.IPAddress }}' $1 2>/dev/null); then
|
||||||
echo "$1 container is not present; have you launched it?" >&2
|
echo "$1 container is not present; have you launched it?" >&2
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
case "$status" in
|
case "$status" in
|
||||||
"true ")
|
"true ")
|
||||||
echo "$1 container has no IP address; is Docker networking enabled?" >&2
|
echo "$1 container has no IP address; is Docker networking enabled?" >&2
|
||||||
exit 1
|
return 1
|
||||||
;;
|
;;
|
||||||
true*)
|
true*)
|
||||||
ip="${status#true }"
|
ip="${status#true }"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$1 container is not running." >&2
|
echo "$1 container is not running." >&2
|
||||||
exit 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift 1
|
shift 1
|
||||||
@@ -313,7 +313,7 @@ http_call_ip() {
|
|||||||
# Perform operation $1 on container ID $2 to local DNS database at address $3
|
# Perform operation $1 on container ID $2 to local DNS database at address $3
|
||||||
# This function is only called where we know $2 is a valid container name
|
# This function is only called where we know $2 is a valid container name
|
||||||
tell_dns() {
|
tell_dns() {
|
||||||
if ! DNSID=$(docker inspect --format='{{ .Id }}' $DNS_CONTAINER_NAME 2>/dev/null) || [ -z "$DNSID" ] ; then
|
if ! status=$(docker inspect --format='{{ .State.Running }}' $DNS_CONTAINER_NAME 2>/dev/null) || [ "$status" != "true" ] ; then
|
||||||
# weavedns not running - silently return
|
# weavedns not running - silently return
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@@ -322,7 +322,7 @@ tell_dns() {
|
|||||||
# extract IP address and routing prefix from CIDR
|
# extract IP address and routing prefix from CIDR
|
||||||
WEAVE_ADDR_IP=$(echo $3 | sed -e 's/\([^/]*\)\/\(.*\)/\1/')
|
WEAVE_ADDR_IP=$(echo $3 | sed -e 's/\([^/]*\)\/\(.*\)/\1/')
|
||||||
MORE_ARGS=$(docker inspect --format='--data-urlencode fqdn={{ .Config.Hostname }}.{{ .Config.Domainname }}.' $CONTAINER 2>/dev/null) && true
|
MORE_ARGS=$(docker inspect --format='--data-urlencode fqdn={{ .Config.Hostname }}.{{ .Config.Domainname }}.' $CONTAINER 2>/dev/null) && true
|
||||||
http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT $1 /name/$CONTAINER/$WEAVE_ADDR_IP $MORE_ARGS
|
http_call $DNS_CONTAINER_NAME $DNS_HTTP_PORT $1 /name/$CONTAINER/$WEAVE_ADDR_IP $MORE_ARGS || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tell the newly-started weaveDNS about existing weave IPs
|
# Tell the newly-started weaveDNS about existing weave IPs
|
||||||
|
|||||||
Reference in new issue
Block a user