From: Vladimir Khlyunev Date: Mon, 15 Apr 2019 06:15:40 +0000 (+0400) Subject: Add job for cleaning up CREATE_FAILED stacks X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=44108011f74c1c04d2b355ad086a187496c4936b;p=tools%2Fsustaining.git Add job for cleaning up CREATE_FAILED stacks Change-Id: I9e2106a4d4ddcc964d45e6c63150d315d150953b --- diff --git a/maintenance-ci/common/jobs/drop-create-failed.yaml b/maintenance-ci/common/jobs/drop-create-failed.yaml new file mode 100644 index 0000000..c1f2a0e --- /dev/null +++ b/maintenance-ci/common/jobs/drop-create-failed.yaml @@ -0,0 +1,25 @@ +- job: + name: 'drop-create-failed' + description: | + Delete all stacks with status "Create Failed" in maintenance-ci tenant + + concurrent: false + node: 'jenkins-master' + + parameters: + - bool: + name: ARE_YOU_SURE + default: false + description: | + Just stub for missclick protection + + wrappers: + - timestamps + - openstack-creds + - timeout: + fail: true + timeout: 30 + + builders: + - shell: + !include-raw: common/scripts/drop_create_failed.sh diff --git a/maintenance-ci/common/scripts/drop_create_failed.sh b/maintenance-ci/common/scripts/drop_create_failed.sh new file mode 100755 index 0000000..23e6c7a --- /dev/null +++ b/maintenance-ci/common/scripts/drop_create_failed.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -ex + +OPENSTACK_CLIENTS_VENV="${OPENSTACK_CLIENTS_VENV:-/home/jenkins/venv-openstack-clients}" + +if [[ ! -d "${OPENSTACK_CLIENTS_VENV}" ]] ; then + virtualenv "${OPENSTACK_CLIENTS_VENV}" + source "${OPENSTACK_CLIENTS_VENV}"/bin/activate + pip install openstackclient + deactivate +fi + +source "${OPENSTACK_CLIENTS_VENV}"/bin/activate + source "${OPENRC_FILE?}" + + for stack in $(openstack stack list --property "stack_status=CREATE_FAILED" -c 'Stack Name' -f value) ; do + openstack stack delete -y "${stack}" + done + +deactivate