-
Notifications
You must be signed in to change notification settings - Fork 35
Upload main images to Arcus S3 and sync clouds #448
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 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1f7c41c
test s3 image sync
bertiethorpe c394a41
fix s3cfg creds
bertiethorpe aebafa5
fix ~/.s3cfg
bertiethorpe b9cf3f4
revert to using secret
bertiethorpe f16a871
multipart chunk image upload
bertiethorpe 75188f7
cleanup s3 at beginning
bertiethorpe 4042ada
move s3 sync to new workflow
bertiethorpe 50c5f19
update packer readme
bertiethorpe 3c1271b
Apply suggestions from code review
bertiethorpe 3e48074
set matrix exclusion dynamically
bertiethorpe 049f4fd
Merge branch 'main' into ci/s3-sync
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,162 @@ | ||
name: Upload CI-tested images to Arcus S3 and sync clouds | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'environments/.stackhpc/terraform/cluster_image.auto.tfvars.json' | ||
env: | ||
S3_BUCKET: openhpc-images-prerelease | ||
IMAGE_PATH: environments/.stackhpc/terraform/cluster_image.auto.tfvars.json | ||
|
||
jobs: | ||
s3_cleanup: | ||
runs-on: ubuntu-22.04 | ||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Write s3cmd configuration | ||
run: | | ||
echo "${{ secrets['ARCUS_S3_CFG'] }}" > ~/.s3cfg | ||
shell: bash | ||
|
||
- name: Install s3cmd | ||
run: | | ||
sudo apt-get --yes install s3cmd | ||
|
||
- name: Cleanup S3 bucket | ||
run: | | ||
s3cmd rm s3://${{ env.S3_BUCKET }} --recursive --force | ||
|
||
image_upload: | ||
runs-on: ubuntu-22.04 | ||
needs: s3_cleanup | ||
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.build }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build: | ||
- RL8 | ||
- RL9 | ||
- RL9-cuda | ||
env: | ||
ANSIBLE_FORCE_COLOR: True | ||
OS_CLOUD: openstack | ||
CI_CLOUD: ${{ vars.CI_CLOUD }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Record which cloud CI is running on | ||
run: | | ||
echo CI_CLOUD: ${{ env.CI_CLOUD }} | ||
|
||
- name: setup environment | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
run: | | ||
python3 -m venv venv | ||
. venv/bin/activate | ||
pip install -U pip | ||
pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt) | ||
shell: bash | ||
|
||
- name: Write clouds.yaml | ||
run: | | ||
mkdir -p ~/.config/openstack/ | ||
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml | ||
shell: bash | ||
|
||
- name: Write s3cmd configuration | ||
run: | | ||
echo "${{ secrets['ARCUS_S3_CFG'] }}" > ~/.s3cfg | ||
shell: bash | ||
|
||
- name: Install s3cmd | ||
run: | | ||
sudo apt-get --yes install s3cmd | ||
|
||
- name: Retrieve image name | ||
run: | | ||
TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}") | ||
echo "TARGET_IMAGE=${TARGET_IMAGE}" >> "$GITHUB_ENV" | ||
shell: bash | ||
|
||
- name: Download image to runner | ||
run: | | ||
. venv/bin/activate | ||
openstack image save --file ${{ env.TARGET_IMAGE }} ${{ env.TARGET_IMAGE }} | ||
shell: bash | ||
|
||
- name: Upload Image to S3 | ||
run: | | ||
echo "Uploading Image: ${{ env.TARGET_IMAGE }} to S3..." | ||
s3cmd --multipart-chunk-size-mb=150 put ${{ env.TARGET_IMAGE }} s3://${{ env.S3_BUCKET }} | ||
shell: bash | ||
|
||
image_sync: | ||
needs: image_upload | ||
runs-on: ubuntu-22.04 | ||
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.cloud }}-${{ matrix.build }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
cloud: | ||
- LEAFCLOUD | ||
- SMS | ||
- ARCUS | ||
build: | ||
- RL8 | ||
- RL9 | ||
- RL9-cuda | ||
exclude: | ||
- cloud: LEAFCLOUD | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
env: | ||
ANSIBLE_FORCE_COLOR: True | ||
OS_CLOUD: openstack | ||
CI_CLOUD: ${{ matrix.cloud }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Record which cloud CI is running on | ||
run: | | ||
echo CI_CLOUD: ${{ env.CI_CLOUD }} | ||
|
||
- name: setup environment | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
run: | | ||
python3 -m venv venv | ||
. venv/bin/activate | ||
pip install -U pip | ||
pip install $(grep -o 'python-openstackclient[><=0-9\.]*' requirements.txt) | ||
shell: bash | ||
|
||
- name: Write clouds.yaml | ||
run: | | ||
mkdir -p ~/.config/openstack/ | ||
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml | ||
shell: bash | ||
|
||
- name: Retrieve image name | ||
run: | | ||
TARGET_IMAGE=$(jq --arg version "${{ matrix.build }}" -r '.cluster_image[$version]' "${{ env.IMAGE_PATH }}") | ||
echo "TARGET_IMAGE=${TARGET_IMAGE}" >> "$GITHUB_ENV" | ||
|
||
- name: Download latest image if missing | ||
run: | | ||
. venv/bin/activate | ||
bash .github/bin/get-s3-image.sh ${{ env.TARGET_IMAGE }} ${{ env.S3_BUCKET }} | ||
|
||
- name: Cleanup OpenStack Image (on error or cancellation) | ||
if: cancelled() | ||
bertiethorpe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
run: | | ||
. venv/bin/activate | ||
image_hanging=$(openstack image list --name ${{ env.TARGET_IMAGE }} -f value -c ID -c Status | grep -v ' active$' | awk '{print $1}') | ||
if [ -n "$image_hanging" ]; then | ||
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 |
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.