Added feature to delete stack if in degraded state

This commit is contained in:
Wayne Connolly
2019-02-24 17:32:57 +11:00
committed by GitHub
parent b4a0b67f79
commit 6c4f5e091f
+11 -2
View File
@@ -19,5 +19,14 @@ echo ""
echo "docker-compose.yml @ ${DOCKER_COMPOSE}"
cat ${DOCKER_COMPOSE}
echo ""
echo "Deploying Rancher Stack with force upgrade"
/bin/rancher --url http://${PLUGIN_URL} --access-key ${ACCESSKEY} --secret-key ${SECRETKEY} up --stack ${PLUGIN_STACK} -d -f ${DOCKER_COMPOSE} --rancher-file ${RANCHER_COMPOSE} --pull --force-recreate --confirm-upgrade
/bin/rancher --url http://${PLUGIN_URL} --access-key ${ACCESSKEY} --secret-key ${SECRETKEY} stacks ls > status
if grep -q degraded status; then
echo 'Stack is degraded. Killing stack now!'
ID=`sed -e 's/\s.*$//' status`
/bin/rancher --url http://${PLUGIN_URL} --access-key ${ACCESSKEY} --secret-key ${SECRETKEY} rm $ID
else
echo 'Stack healthy or not found. Creating/Updating stack with force upgrade'
/bin/rancher --url http://${PLUGIN_URL} --access-key ${ACCESSKEY} --secret-key ${SECRETKEY} up --stack ${PLUGIN_STACK} -d -f ${DOCKER_COMPOSE} --rancher-file ${RANCHER_COMPOSE} --pull --force-recreate --confirm-upgrade
fi