|
|
c608c9 |
From 05fb27218f3b8a78bff0b0e668c8d38feeb93dca Mon Sep 17 00:00:00 2001
|
|
|
c608c9 |
From: David Vossel <dvossel@redhat.com>
|
|
|
c608c9 |
Date: Thu, 23 Oct 2014 14:20:14 -0400
|
|
|
c608c9 |
Subject: [PATCH] High: docker: properly remove stale container during stop
|
|
|
c608c9 |
when 'reuse' is not enabled
|
|
|
c608c9 |
|
|
|
c608c9 |
---
|
|
|
c608c9 |
heartbeat/docker | 11 ++++++++++-
|
|
|
c608c9 |
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
|
c608c9 |
|
|
|
c608c9 |
diff --git a/heartbeat/docker b/heartbeat/docker
|
|
|
c608c9 |
index 546c423..37a449b 100755
|
|
|
c608c9 |
--- a/heartbeat/docker
|
|
|
c608c9 |
+++ b/heartbeat/docker
|
|
|
c608c9 |
@@ -157,6 +157,11 @@ remove_container()
|
|
|
c608c9 |
return 0
|
|
|
c608c9 |
fi
|
|
|
c608c9 |
|
|
|
c608c9 |
+ container_exists
|
|
|
c608c9 |
+ if [ $? -ne 0 ]; then
|
|
|
c608c9 |
+ # don't attempt to remove a container that doesn't exist
|
|
|
c608c9 |
+ return 0
|
|
|
c608c9 |
+ fi
|
|
|
c608c9 |
ocf_log notice "Cleaning up inactive container, ${CONTAINER}."
|
|
|
c608c9 |
ocf_run docker rm $CONTAINER
|
|
|
c608c9 |
}
|
|
|
c608c9 |
@@ -210,7 +215,10 @@ docker_start()
|
|
|
c608c9 |
if ocf_is_true "$OCF_RESKEY_reuse" && container_exists; then
|
|
|
c608c9 |
ocf_log info "starting existing container $CONTAINER."
|
|
|
c608c9 |
ocf_run docker start $CONTAINER
|
|
|
c608c9 |
- else
|
|
|
c608c9 |
+ else
|
|
|
c608c9 |
+ # make sure any previous container matching our container name is cleaned up first.
|
|
|
c608c9 |
+ # we already know at this point it wouldn't be running
|
|
|
c608c9 |
+ remove_container
|
|
|
c608c9 |
ocf_log info "running container $CONTAINER for the first time"
|
|
|
c608c9 |
ocf_run docker run $run_opts $OCF_RESKEY_image $OCF_RESKEY_run_cmd
|
|
|
c608c9 |
fi
|
|
|
c608c9 |
@@ -234,6 +242,7 @@ docker_stop()
|
|
|
c608c9 |
local timeout=60
|
|
|
c608c9 |
docker_monitor
|
|
|
c608c9 |
if [ $? -eq $OCF_NOT_RUNNING ]; then
|
|
|
c608c9 |
+ remove_container
|
|
|
c608c9 |
return $OCF_SUCCESS
|
|
|
c608c9 |
fi
|
|
|
c608c9 |
|
|
|
c608c9 |
--
|
|
|
c608c9 |
1.8.4.2
|
|
|
c608c9 |
|