removal. (default: 30)
:openstack-image-protect: Whether or not to run the image protect script.
(default: true)
+ :openstack-volume-cleanup: Whether or not to run the volume cleanup script.
+ (default: true)
:stream: Keyword that can be used to represent a release code-name.
Often the same as the branch. (default: master)
:submodule-recursive: Whether to checkout submodules recursively.
openstack-image-cleanup: true
openstack-image-cleanup-age: 30
openstack-image-protect: true
+ openstack-volume-cleanup: true
stream: master
submodule-timeout: 10
- lf-infra-pre-build
- inject:
properties-content: OS_CLOUD={openstack-cloud}
+ # Volumes
+ - conditional-step:
+ condition-kind: boolean-expression
+ condition-expression: '{openstack-volume-cleanup}'
+ steps:
+ - shell: !include-raw-escape: ../shell/openstack-cleanup-orphaned-volumes.sh
# Images
- conditional-step:
condition-kind: boolean-expression
--- /dev/null
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+# Scans OpenStack for orphaned volumes
+echo "---> Orphaned volumes"
+
+os_cloud="${OS_CLOUD:-vex}"
+
+set -eux -o pipefail
+
+mapfile -t os_volumes < <(openstack --os-cloud "$os_cloud" volume list -f value -c ID --status Available)
+
+if [ ${#os_volumes[@]} -eq 0 ]; then
+ echo "No orphaned volumes found."
+else
+ for volume in "${os_volumes[@]}"; do
+ echo "Removing volume $volume"
+ lftools openstack --os-cloud "$os_cloud" volume remove --minutes 15 "$volume"
+ done
+fi