Skip to content

Commit 591f5cf

Browse files
authored
Merge pull request #941 from stackhpc/yoga-aio-tags
CI: Add tags to aio VMs, periodically clean up stale aio instances (yoga)
2 parents 98cfeba + 186a03c commit 591f5cf

File tree

6 files changed

+69
-3
lines changed

6 files changed

+69
-3
lines changed

.github/workflows/overcloud-host-image-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jobs:
139139
- name: Install OpenStack client
140140
run: |
141141
source venvs/kayobe/bin/activate &&
142-
pip install python-openstackclient -c https://opendev.org/openstack/requirements/raw/branch/stable/${{ steps.openstack_release.outputs.openstack_release }}/upper-constraints.txt
142+
pip install python-openstackclient -c https://releases.openstack.org/constraints/upper/${{ steps.openstack_release.outputs.openstack_release }}
143143
144144
- name: Build a CentOS Stream 8 overcloud host image
145145
id: build_centos_stream_8

.github/workflows/overcloud-host-image-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
- name: Install OpenStack client
9393
run: |
9494
source venvs/kayobe/bin/activate &&
95-
pip install python-openstackclient -c https://opendev.org/openstack/requirements/raw/branch/stable/yoga/upper-constraints.txt
95+
pip install python-openstackclient -c https://releases.openstack.org/constraints/upper/${{ steps.openstack_release.outputs.openstack_release }}
9696
9797
- name: Output CentOS Stream 8 image tag
9898
id: centos_8_stream_image_tag

.github/workflows/stackhpc-all-in-one.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ jobs:
134134
aio_vm_flavor = "${{ env.VM_FLAVOR }}"
135135
aio_vm_network = "${{ env.VM_NETWORK }}"
136136
aio_vm_subnet = "${{ env.VM_SUBNET }}"
137+
aio_vm_tags = ${{ env.VM_TAGS }}
137138
EOF
138139
working-directory: ${{ github.workspace }}/terraform/aio
139140
env:
@@ -144,6 +145,7 @@ jobs:
144145
VM_NETWORK: ${{ inputs.vm_network }}
145146
VM_SUBNET: ${{ inputs.vm_subnet }}
146147
VM_INTERFACE: ${{ inputs.vm_interface }}
148+
VM_TAGS: '["skc-ci-aio", "PR=${{ github.event.number }}"]'
147149

148150
- name: Terraform Plan
149151
run: terraform plan
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name: Clean up stale CI resources
3+
on:
4+
schedule:
5+
# Every 2 hours at quarter past
6+
- cron: '15 0/2 * * *'
7+
8+
jobs:
9+
ci-cleanup:
10+
name: Clean up stale CI resources
11+
if: github.repository == 'stackhpc/stackhpc-kayobe-config'
12+
runs-on: ubuntu-latest
13+
permissions: {}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
path: src/kayobe-config
19+
20+
- name: Setup Python
21+
uses: actions/setup-python@v5
22+
23+
- name: Generate clouds.yaml
24+
run: |
25+
cat << EOF > clouds.yaml
26+
${{ secrets.CLOUDS_YAML }}
27+
EOF
28+
29+
- name: Determine OpenStack release
30+
id: openstack_release
31+
run: |
32+
BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' src/kayobe-config/.gitreview)
33+
echo "openstack_release=${BRANCH}" | sed "s|stable/||" >> $GITHUB_OUTPUT
34+
35+
- name: Install OpenStack client
36+
run: |
37+
pip install python-openstackclient -c https://releases.openstack.org/constraints/upper/${{ steps.openstack_release.outputs.openstack_release }}
38+
39+
- name: Clean up aio instances over 3 hours old
40+
run: |
41+
result=0
42+
changes_before=$(date -Imin -d -3hours)
43+
for status in ACTIVE BUILD ERROR SHUTOFF; do
44+
for instance in $(openstack server list --tags skc-ci-aio --os-compute-api-version 2.66 --format value --column ID --changes-before $changes_before --status $status); do
45+
echo "Cleaning up $status instance $instance"
46+
openstack server show $instance
47+
if ! openstack server delete $instance; then
48+
echo "Failed to delete $status instance $instance"
49+
result=1
50+
fi
51+
done
52+
done
53+
exit $result
54+
env:
55+
OS_CLOUD: openstack
56+
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
57+
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# A 'seed' host used for building images.
22
[seed]
3-
builder
3+
localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3

terraform/aio/vm.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ variable "aio_vm_volume_size" {
3838
default = 35
3939
}
4040

41+
variable "aio_vm_tags" {
42+
type = list(string)
43+
default = []
44+
}
45+
4146
locals {
4247
image_is_uuid = length(regexall("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", var.aio_vm_image)) > 0
4348
}
@@ -69,6 +74,8 @@ resource "openstack_compute_instance_v2" "kayobe-aio" {
6974
destination_type = "volume"
7075
delete_on_termination = true
7176
}
77+
78+
tags = var.aio_vm_tags
7279
}
7380

7481
# Wait for the instance to be accessible via SSH before progressing.

0 commit comments

Comments
 (0)