Remove container dependencies on sysinv-conductor shutdown

After an application apply, a docker armada container is created and
running to handle any subsequent armada commands. This container mounts
directories in /opt/platform to get access to the armada manifests and
the helm chart overrides. This running container will prevent a swact
from occurring as the DRBD resource is held open.

Update the OCF script to stop and remove the armada container after the
sysinv-conductor has been confirmed to be stopped.

Change-Id: Ia123270616a2849bb30934df09f6947023d0caba
Story: 2003908
Task: 28124
Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
Robert Church 2018-11-29 11:12:08 -05:00
parent 27cdaf8620
commit ddc8dd3bc6
1 changed files with 43 additions and 0 deletions

View File

@ -224,6 +224,44 @@ sysinv_conductor_start () {
return ${rc}
}
sysinv_remove_application_containers() {
local containers='armada_service'
local rc
# The entry point for this is when the conductor has been confirmed to be
# stopped. Now cleanup any dependent service containers. This will be done
# here until we re-factor the management of (i.e. catch SIGKILL and cleanup)
# or the retirement of (i.e. move armada to a pod) these dependencies
# On a non K8S configuration docker status will be EXIT_NOTIMPLEMENTED
systemctl status docker 2>&1 >> /dev/null
rc=$?
if [ $rc -eq 3 ]; then
ocf_log info "${proc} Docker is not running, skipping container actions. (sysinv-conductor)"
return
fi
# Shutdown containers with DRBD dependencies that would prevent a swact.
for c in $containers; do
local id
# does the container exist
id=$(docker container ls -qf name=${c} 2>/dev/null)
if [ ! -n "$id" ]; then
ocf_log info "${proc} Container $c is not present, skipping container actions. (sysinv-conductor)"
continue
fi
# Graceful shutdown (default is 10 sec, then kill)
ocf_log info "${proc} About to stop container $c... (sysinv-conductor)"
docker stop $c 2>&1 >> /dev/null
# Cleanup the container. Use force just in case.
ocf_log info "${proc} About to remove container $c... (sysinv-conductor)"
docker rm -f $c 2>&1 >> /dev/null
done
}
sysinv_conductor_confirm_stop() {
local my_bin
local my_processes
@ -252,6 +290,9 @@ sysinv_conductor_stop () {
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "${proc} Sysinv Conductor (sysinv-conductor) already stopped"
sysinv_conductor_confirm_stop
sysinv_remove_application_containers
return ${OCF_SUCCESS}
fi
@ -292,6 +333,8 @@ sysinv_conductor_stop () {
fi
sysinv_conductor_confirm_stop
sysinv_remove_application_containers
ocf_log info "${proc} Sysinv Conductor (sysinv-conductor) stopped."
rm -f $OCF_RESKEY_pid