Skip to content

Commit b2c6e82

Browse files
priteauAlex-Welsh
authored andcommitted
CI: Add cleanup of DOCA builder instances
1 parent 1b17a95 commit b2c6e82

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.github/workflows/package-build-ofed.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ jobs:
9797
aio_vm_network = "stackhpc-ci"
9898
aio_vm_subnet = "stackhpc-ci"
9999
aio_vm_interface = "ens3"
100+
aio_vm_tags = ${{ env.VM_TAGS }}
100101
EOF
101102
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
102103
env:
103104
VM_IMAGE: ${{ steps.image_name.outputs.image_name }}
105+
VM_TAGS: '["skc-ci-doca-builder", "PR=${{ github.event.number }}"]'
104106

105107
- name: Terraform Plan
106108
run: terraform plan

.github/workflows/stackhpc-ci-cleanup.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ jobs:
6060
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
6161
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
6262

63+
- name: Clean up DOCA builder instances over 5 hours old
64+
run: |
65+
result=0
66+
changes_before=$(date -Imin -d -5hours)
67+
for status in ACTIVE BUILD ERROR SHUTOFF; do
68+
for instance in $(openstack server list --tags skc-ci-doca-builder --os-compute-api-version 2.66 --format value --column ID --changes-before $changes_before --status $status); do
69+
echo "Cleaning up $status instance $instance"
70+
openstack server show $instance
71+
if ! openstack server delete $instance; then
72+
echo "Failed to delete $status instance $instance"
73+
result=1
74+
fi
75+
done
76+
done
77+
exit $result
78+
env:
79+
OS_CLOUD: ${{ vars.OS_CLOUD }}
80+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
81+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
82+
6383
- name: Clean up host image builder instances over 5 hours old
6484
run: |
6585
result=0

0 commit comments

Comments
 (0)