Skip to content

Commit b23b0cd

Browse files
bertiethorpeMaxBed4d
authored andcommitted
suggested changes
1 parent 3d0dde7 commit b23b0cd

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ bucket_name=$2
1212
echo "Checking if image $image_name exists in OpenStack"
1313
image_exists=$(openstack image list --name "$image_name" -f value -c Name)
1414

15-
if [ "$image_exists" == "$image_name" ]; then
15+
if [ -n $image_exists ]; then
1616
echo "Image $image_name already exists in OpenStack."
1717
else
1818
echo "Image $image_name not found in OpenStack. Getting it from S3."
1919

2020
wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/$bucket_name/$image_name --progress=dot:giga
2121

2222
echo "Uploading image $image_name to OpenStack..."
23-
openstack image create --file "$image_name" --disk-format qcow2 "$image_name" --progress
23+
openstack image create --file $image_name --disk-format qcow2 $image_name --progress
2424

2525
echo "Image $image_name has been uploaded to OpenStack."
2626
fi

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
# This workflow dispatch is to be used on a downstream ansible-slurm-appliance repository. The workflow takes two inputs:
2-
# image name, and s3 bucket name. The image is searched for in the environment set openstack, and if not found there,
3-
# downloads it from the ARCUS S3 bucket specified. The workflow then uploads the image to the openstack.
1+
# This workflow can be used to fetch images published by StackHPC and upload them to a client's OpenStack.
2+
# The workflow takes two inputs:
3+
# - image name
4+
# - s3 bucket name
5+
# and first checks to see if the image exists in the target OpenStack. If the image doesn't exist, it is downloaded
6+
# from StackHPC's public S3 bucket and then uploaded to the target OpenStack.
47
#
58
# To use this workflow in a downstream ansible-slurm-appliance repository simply copy it into .github/workflows
69
# and give it an appropriate name, e.g.
710
# cp .github/workflows/upload-s3-image.yml.sample .github/workflows/upload-s3-image.yml
811
#
9-
# In order for the workflow to access the openstack, credentials in the form of a clouds.yaml file must be provided by a
10-
# secret. This secret should have the name OS_CLOUD_YAML to be found by the workflow.
12+
# In order for the workflow to access the target OpenStack, an application credential clouds.yaml file must be
13+
# added as a repository secret named OS_CLOUD_YAML.
1114
# Details on the contents of the clouds.yaml file can be found at https://docs.openstack.org/keystone/latest/user/application_credentials.html
1215

1316
name: Upload release images to client sites from s3
@@ -53,15 +56,11 @@ jobs:
5356
if: cancelled()
5457
run: |
5558
. venv/bin/activate
56-
image_hanging=$(openstack image list --name ${{ inputs.image_name }} -f value -c ID)
57-
if [ -n "$image_hanging" ]; then
59+
image_hanging=$(openstack image list --name ${{ inputs.image_name }} -f value -c ID -c Status | grep -v ' queued$' | awk '{print $1}'
60+
if [ -n $image_hanging ]; then
5861
echo "Cleaning up OpenStack image with ID: $image_hanging"
5962
openstack image delete $image_hanging
6063
else
6164
echo "No image ID found, skipping cleanup."
6265
fi
63-
shell: bash
64-
65-
- name: Confirm Success
66-
if: success()
67-
run: echo "Deployment succeeded, no cleanup needed."
66+
shell: bash

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,4 @@ The `.github` directory contains a set of sample workflows which can be used by
151151

152152
- An [upgrade check](.github/workflows/upgrade-check.yml.sample) workflow which automatically checks this upstream stackhpc/ansible-slurm-appliance repo for new releases and proposes a pull request to the downstream site-specific repo when a new release is published.
153153

154-
- An [image upload](.github/workflows/upload-s3-image.yml.sample) workflow dispatch which takes an image name, downloads it from ARCUS s3 bucket if available, and uploads to downstream environment openstack.
154+
- An [image upload](.github/workflows/upload-s3-image.yml.sample) workflow which takes an image name, downloads it from StackHPC's public S3 bucket if available, and uploads it to the target OpenStack cloud.

0 commit comments

Comments
 (0)