Skip to content

Commit 04e30fc

Browse files
committed
pick bucket and handle cancellation
1 parent 4207bff commit 04e30fc

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

.github/bin/get-s3-image.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -ex
44

55
image_name=$1
6+
bucket_name=$2
67
echo "Checking if image $image_name exists in OpenStack"
78
image_exists=$(openstack image list --name "$image_name" -f value -c Name)
89

@@ -11,7 +12,7 @@ if [ "$image_exists" == "$image_name" ]; then
1112
else
1213
echo "Image $image_name not found in OpenStack. Getting it from S3."
1314

14-
wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/openhpc-images/$image_name --progress=dot:giga
15+
wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/$bucket_name/$image_name --progress=dot:giga
1516

1617
echo "Uploading image $image_name to OpenStack..."
1718
openstack image create --file "$image_name" --disk-format qcow2 "$image_name" --progress

.github/workflows/upload-release-image.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ on:
55
inputs:
66
image_name:
77
type: string
8-
description: Image name from https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/openhpc-images/
8+
description: Image name from https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/{BUCKET_NAME}/
99
required: true
10-
11-
# push:
12-
# branches:
13-
# - main
14-
# - master
15-
# - feat/fatimage-auto-upload
10+
bucket_name:
11+
type: choice
12+
required: true
13+
description: Bucket name
14+
options:
15+
- openhpc-images
16+
# - openhpc-images-prerelease
1617

1718
jobs:
1819
image_upload:
1920
runs-on: ubuntu-22.04
2021
concurrency: ${{ github.ref }}
2122
env:
2223
OS_CLOUD: openstack
23-
IMAGE_LIST: "RL8 RL9"
2424
steps:
2525
- uses: actions/checkout@v4
2626

@@ -36,4 +36,21 @@ jobs:
3636
. venv/bin/activate
3737
pip install -U pip
3838
pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt)
39-
bash .github/bin/get-s3-image.sh ${{ inputs.image_name }}
39+
bash .github/bin/get-s3-image.sh ${{ inputs.image_name }} ${{ inputs.bucket_name }}
40+
41+
- name: Cleanup OpenStack Image (on error or cancellation)
42+
if: cancelled()
43+
run: |
44+
. venv/bin/activate
45+
image_hanging=$(openstack image list --name ${{ inputs.image_name }} -f value -c ID)
46+
if [ -n "$image_hanging" ]; then
47+
echo "Cleaning up OpenStack image with ID: $image_hanging"
48+
openstack image delete $image_hanging
49+
else
50+
echo "No image ID found, skipping cleanup."
51+
fi
52+
shell: bash
53+
54+
- name: Confirm Success
55+
if: success()
56+
run: echo "Deployment succeeded, no cleanup needed."

0 commit comments

Comments
 (0)