Only delete stack at end of job if CREATE_[COMPLETE|FAILED] status 90/50990/3
authorThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 25 Jan 2017 05:02:52 +0000 (21:02 -0800)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 25 Jan 2017 05:27:42 +0000 (21:27 -0800)
This patch will make the post build cleanup script only clear
stacks with CREATE_COMPLETE and CREATE_FAILED statuses.

Let the periodic cleanup job clear CREATE_FAILED and DELETE_FAILED
statuses. This is to help Rackspace troubleshoot our orchestration
stacks getting stuck in Rackspace.

Change-Id: I6fe75fe380508533bd440297e32bdddce2a7cc71
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/releng-macros.yaml

index 286cb4641592635ed7de4232c93f823aa997cebc..0371d28a57911b9c5c6c7a21b2300ffb36f03b2b 100644 (file)
                 - shell: |
                     if [ -d "$WORKSPACE/.venv-openstack" ]; then
                         source $WORKSPACE/.venv-openstack/bin/activate
-                        openstack --os-cloud rackspace stack delete --yes $STACK_NAME
+                        OS_STATUS=`openstack --os-cloud rackspace stack show -f json -c stack_status $STACK_NAME | jq -r '.stack_status'`
+                        if [ "$OS_STATUS" == "CREATE_COMPLETE" ] || [ "$OS_STATUS" == "CREATE_FAILED" ]; then
+                            echo "Deleting $STACK_NAME"
+                            openstack --os-cloud rackspace stack delete --yes $STACK_NAME
+                        fi
                     fi
                 - shell: !include-raw: include-raw-deploy-archives.sh
                 - maven-target: