-
Notifications
You must be signed in to change notification settings - Fork 35
Add workflow to cleanup CI clusters #451
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 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e1fdc94
add CI to cleanup ci clusters
sjpb 3c080c3
change CI cluster cleanup to be earlier to save $
sjpb 83ca12e
Merge branch 'main' into ci/cleanup-ci-clusters
sjpb 7fbdd36
Merge branch 'main' into ci/cleanup-ci-clusters
sjpb 78ded79
don't trigger deployment/reimage workflow on changes to workflows oth…
sjpb 45e211e
Apply fixes to CI cleanup workflow from code review
sjpb 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,71 @@ | ||
name: Cleanup CI clusters | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ci_cloud: | ||
description: 'Select the CI_CLOUD' | ||
required: true | ||
type: choice | ||
options: | ||
- LEAFCLOUD | ||
- SMS | ||
- ARCUS | ||
schedule: | ||
- cron: '0 20 * * *' # Run at 8PM - image sync runs at midnight | ||
|
||
jobs: | ||
ci_cleanup: | ||
name: ci-cleanup | ||
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.cloud }}-${{ matrix.build }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
cloud: | ||
- LEAFCLOUD | ||
- SMS | ||
- ARCUS | ||
runs-on: ubuntu-22.04 | ||
env: | ||
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 | ||
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: Find CI clusters | ||
run: | | ||
. venv/bin/activate | ||
CI_CLUSTERS=$(openstack server list | grep --only-matching 'slurmci-RL.-[0-9]\+' | sort | uniq) | ||
echo "ci_clusters=${CI_CLUSTERS}" >> GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Delete clusters if control node not tagged with keep | ||
run: | | ||
. venv/bin/activate | ||
for cluster_prefix in ${CI_CLUSTERS} | ||
do | ||
TAGS=$(openstack server show ${cluster_prefix}-control --column tags --format value) | ||
if [[ TAGS =~ "keep" ]]; then | ||
sjpb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
echo "Skipping ${cluster_prefix} - control instance is tagged as keep" | ||
else | ||
yes | ./dev/delete-cluster.py ${cluster_prefix} | ||
fi | ||
done | ||
shell: bash |
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.