Refactor: extract kill_container function

This commit is contained in:
Bryan Boreham committed 2016-05-06 15:45:54 +01:00
1 parent 5993b3e846
commit 01e3d1d81b
1 file changed
+7 -3
+7 -3
View File
@@ -828,9 +828,13 @@ with_container_netns() {
return $STATUS return $STATUS
} }
kill_container() {
docker kill $1 >/dev/null 2>&1 || true
}
with_container_netns_or_die() { with_container_netns_or_die() {
if ! with_container_netns "$@" >/dev/null ; then if ! with_container_netns "$@" >/dev/null ; then
docker kill $1 >/dev/null 2>&1 || true kill_container $1
exit 1 exit 1
fi fi
} }
@@ -1129,7 +1133,7 @@ wait_for_status() {
while true ; do while true ; do
"$@" GET /status >/dev/null 2>&1 && return 0 "$@" GET /status >/dev/null 2>&1 && return 0
if ! check_running $container >/dev/null 2>&1 ; then if ! check_running $container >/dev/null 2>&1 ; then
docker kill $container >/dev/null 2>&1 || true # stop it restarting kill_container $container # stop it restarting
echo $(death_msg $container) >&2 echo $(death_msg $container) >&2
return 1 return 1
fi fi
@@ -1451,7 +1455,7 @@ ipam_cidrs() {
ipam_cidrs_or_die() { ipam_cidrs_or_die() {
if ! ipam_cidrs "$@" ; then if ! ipam_cidrs "$@" ; then
docker kill $2 >/dev/null 2>&1 || true kill_container $2
exit 1 exit 1
fi fi
} }