Skip to content

Commit

Permalink
Merge pull request #532 from stackhpc/fix/nightly-cleanup
Browse files Browse the repository at this point in the history
Fix nightly cleanup to deal with duplicate server names
  • Loading branch information
bertiethorpe authored Jan 14, 2025
2 parents 2903223 + edbcebc commit 662f5ef
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/nightly-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,31 @@ jobs:
for cluster_prefix in ${ci_clusters}
do
echo "Processing cluster: $cluster_prefix"
TAGS=$(openstack server show ${cluster_prefix}-control --column tags --format value)
if [[ $TAGS =~ "keep" ]]; then
echo "Skipping ${cluster_prefix} - control instance is tagged as keep"
# Get all servers with the matching name for control node
CONTROL_SERVERS=$(openstack server list --name ${cluster_prefix}-control --format json)
SERVER_COUNT=$(echo "$CONTROL_SERVERS" | jq length)
if [[ $SERVER_COUNT -gt 1 ]]; then
echo "Multiple servers found for control node '${cluster_prefix}-control'. Checking tags for each..."
for server in $(echo "$CONTROL_SERVERS" | jq -r '.[].ID'); do
# Get tags for each control node
TAGS=$(openstack server show "$server" --column tags --format value)
if [[ $TAGS =~ "keep" ]]; then
echo "Skipping ${cluster_prefix} (server ${server}) - control instance is tagged as keep"
else
./dev/delete-cluster.py ${cluster_prefix} --force
fi
done
else
./dev/delete-cluster.py ${cluster_prefix} --force
# If only one server, extract its tags and proceed
TAGS=$(echo "$CONTROL_SERVERS" | jq -r '.[0].Tags')
if [[ $TAGS =~ "keep" ]]; then
echo "Skipping ${cluster_prefix} - control instance is tagged as keep"
else
./dev/delete-cluster.py ${cluster_prefix} --force
fi
fi
done
shell: bash

0 comments on commit 662f5ef

Please sign in to comment.