Skip to content

Commit f393bfd

Browse files
committed
CI: Clean openstack volumes
The hack/ci/openstack.sh script creates servers that boot from volumes. These volumes were not cleaned up before. With this commit the volumes are created explicitly with the same name as the servers and then deleted together with them.
1 parent df4ac36 commit f393bfd

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

hack/ci/create_devstack.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# limitations under the License.
1616

1717
# hack script for preparing devstack to run cluster-api-provider-openstack e2e
18-
# This script is invoked by devstack-on-*-project-install.sh
18+
# This script invokes the ${RESOURCE_TYPE}.sh scripts to set up the infrastructure
19+
# needed for running devstack.
1920

2021
set -x
2122
set -o errexit -o nounset -o pipefail

hack/ci/openstack.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# hack script for preparing GCP to run cluster-api-provider-openstack e2e
17+
# hack script for preparing Openstack to run cluster-api-provider-openstack e2e
1818

1919
set -x -o errexit -o nounset -o pipefail
2020

@@ -109,13 +109,24 @@ function create_vm {
109109
secgroupid=${secgroupid:-${OPENSTACK_SECGROUP_NAME}}
110110
imageid=${imageid:-${OPENSTACK_IMAGE_NAME}}
111111

112+
local volumename="${CLUSTER_NAME}-${name}"
113+
local volumeid
114+
if ! volumeid=$(openstack volume show "$volumename" -f value -c id 2>/dev/null)
115+
then
116+
volumeid=$(openstack volume create -f value -c id --size 200 \
117+
--bootable --image "$imageid" "$volumename")
118+
while [ "$(openstack volume show "$volumename" -f value -c status 2>/dev/null)" != "available" ]; do
119+
echo "Waiting for volume to become available"
120+
sleep 5
121+
done
122+
fi
123+
112124
local serverid
113125
if ! serverid=$(openstack server show "$servername" -f value -c id 2>/dev/null)
114126
then
115127
serverid=$(openstack server create -f value -c id \
116128
--os-compute-api-version 2.52 --tag "$CLUSTER_NAME" \
117-
--image "$imageid" --flavor "$flavor" \
118-
--boot-from-volume 200 \
129+
--flavor "$flavor" --volume "$volumeid" \
119130
--nic net-id="$networkid",v4-fixed-ip="$ip" \
120131
--security-group "$secgroupid" \
121132
--user-data "$userdata" \
@@ -157,6 +168,9 @@ function cloud_cleanup {
157168
if ! openstack server delete --wait "$name"; then
158169
openstack server show "$name" && exit 1
159170
fi
171+
if ! openstack volume delete "$name"; then
172+
openstack volume show "$name" && exit 1
173+
fi
160174
done
161175

162176
for routerid in $(openstack router list --tag "$CLUSTER_NAME" -f value -c ID); do

0 commit comments

Comments
 (0)