-
Notifications
You must be signed in to change notification settings - Fork 35
Add workflow for fat image uploads to client sites #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0b9a219
test upload images commit
bertiethorpe 706832d
just use workflow_dispatch
bertiethorpe e7b45e2
Merge pull request #2 from stackhpc/feat/fatimage-auto-upload
bertiethorpe e6e57c6
test upload images commit
bertiethorpe 7c34aca
just use workflow_dispatch
bertiethorpe 4226650
fix cloud config parse
bertiethorpe bbfa50f
fix image create name
bertiethorpe d044560
pick bucket and handle cancellation
bertiethorpe 8f10dfe
documentation
bertiethorpe a5a1c03
suggested changes
bertiethorpe 2fd26d5
Merge branch 'main' into feat/fatimage-auto-upload
bertiethorpe 503632d
Merge pull request #3 from stackhpc/feat/fatimage-auto-upload
bertiethorpe af22aa8
make workflow available
bertiethorpe ea8526e
filter out active images
bertiethorpe 7682c88
fix image exists
bertiethorpe a9b0976
fix image test logic
bertiethorpe 5b4cb94
add quotes to var
bertiethorpe 58667c8
finalise for upstream
bertiethorpe 8413cfa
markdown test
bertiethorpe a22660a
markdown block text
bertiethorpe ebc94c2
finish
bertiethorpe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
##### | ||
# This script looks for an image in OpenStack and if not found, downloads from | ||
# S3 bucket, and then uploads to OpenStack | ||
##### | ||
|
||
set -ex | ||
|
||
image_name=$1 | ||
bucket_name=$2 | ||
echo "Checking if image $image_name exists in OpenStack" | ||
image_exists=$(openstack image list --name "$image_name" -f value -c Name) | ||
|
||
if [ "$image_exists" == "$image_name" ]; then | ||
echo "Image $image_name already exists in OpenStack." | ||
else | ||
echo "Image $image_name not found in OpenStack. Getting it from S3." | ||
|
||
wget https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/$bucket_name/$image_name --progress=dot:giga | ||
|
||
echo "Uploading image $image_name to OpenStack..." | ||
openstack image create --file "$image_name" --disk-format qcow2 "$image_name" --progress | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
echo "Image $image_name has been uploaded to OpenStack." | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# This workflow dispatch is to be used on a downstream ansible-slurm-appliance repository. The workflow takes two inputs: | ||
# image name, and s3 bucket name. The image is searched for in the environment set openstack, and if not found there, | ||
# downloads it from the ARCUS S3 bucket specified. The workflow then uploads the image to the openstack. | ||
# | ||
# To use this workflow in a downstream ansible-slurm-appliance repository simply copy it into .github/workflows | ||
# and give it an appropriate name, e.g. | ||
# cp .github/workflows/upload-s3-image.yml.sample .github/workflows/upload-s3-image.yml | ||
# | ||
# In order for the workflow to access the openstack, credentials in the form of a clouds.yaml file must be provided by a | ||
# secret. This secret should have the name OS_CLOUD_YAML to be found by the workflow. | ||
# Details on the contents of the clouds.yaml file can be found at https://docs.openstack.org/keystone/latest/user/application_credentials.html | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
name: Upload release images to client sites from s3 | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
image_name: | ||
type: string | ||
description: Image name from https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_3a06571936a0424bb40bc5c672c4ccb1/{BUCKET_NAME}/ | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
required: true | ||
bucket_name: | ||
type: choice | ||
required: true | ||
description: Bucket name | ||
options: | ||
- openhpc-images | ||
# - openhpc-images-prerelease | ||
|
||
jobs: | ||
image_upload: | ||
runs-on: ubuntu-22.04 | ||
concurrency: ${{ github.ref }} | ||
bertiethorpe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
env: | ||
OS_CLOUD: openstack | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Write clouds.yaml | ||
run: | | ||
mkdir -p ~/.config/openstack/ | ||
echo "${{ secrets.OS_CLOUD_YAML }}" > ~/.config/openstack/clouds.yaml | ||
shell: bash | ||
|
||
- name: Upload latest image if missing | ||
run: | | ||
python3 -m venv venv | ||
. venv/bin/activate | ||
pip install -U pip | ||
pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt) | ||
bash .github/bin/get-s3-image.sh ${{ inputs.image_name }} ${{ inputs.bucket_name }} | ||
|
||
- name: Cleanup OpenStack Image (on error or cancellation) | ||
if: cancelled() | ||
run: | | ||
. venv/bin/activate | ||
image_hanging=$(openstack image list --name ${{ inputs.image_name }} -f value -c ID) | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if [ -n "$image_hanging" ]; then | ||
bertiethorpe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "Cleaning up OpenStack image with ID: $image_hanging" | ||
openstack image delete $image_hanging | ||
else | ||
echo "No image ID found, skipping cleanup." | ||
fi | ||
shell: bash | ||
|
||
- name: Confirm Success | ||
if: success() | ||
run: echo "Deployment succeeded, no cleanup needed." | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.