]> review.fuel-infra Code Review - tools/sustaining.git/commitdiff
Add job for cleaning up CREATE_FAILED stacks 53/41053/3
authorVladimir Khlyunev <vkhlyunev@mirantis.com>
Mon, 15 Apr 2019 06:15:40 +0000 (10:15 +0400)
committerVladimir Khlyunev <vkhlyunev@mirantis.com>
Mon, 15 Apr 2019 06:18:00 +0000 (10:18 +0400)
Change-Id: I9e2106a4d4ddcc964d45e6c63150d315d150953b

maintenance-ci/common/jobs/drop-create-failed.yaml [new file with mode: 0644]
maintenance-ci/common/scripts/drop_create_failed.sh [new file with mode: 0755]

diff --git a/maintenance-ci/common/jobs/drop-create-failed.yaml b/maintenance-ci/common/jobs/drop-create-failed.yaml
new file mode 100644 (file)
index 0000000..c1f2a0e
--- /dev/null
@@ -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 (executable)
index 0000000..23e6c7a
--- /dev/null
@@ -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