Skip to content

Commit 9e65602

Browse files
authored
Merge pull request #660 from stackhpc/fix/nightly-cleanup-2
Fix nightly-cleanup workflow
2 parents 4ef0c82 + 4ea2954 commit 9e65602

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/nightly-cleanup.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,34 @@ jobs:
5959
- name: Delete CI clusters
6060
run: |
6161
. venv/bin/activate
62-
if [[ -z "${ci_clusters}" ]]; then
62+
if [[ -z ${ci_clusters} ]]; then
6363
echo "No clusters to delete."
6464
exit 0
6565
fi
66-
echo "Deleting clusters: ${ci_clusters}"
67-
./dev/delete-cluster.py ${ci_clusters} --force
66+
67+
for cluster_prefix in ${ci_clusters}
68+
do
69+
echo "Processing cluster: $cluster_prefix"
70+
71+
# Get all servers with the matching name for control node
72+
CONTROL_SERVERS=$(openstack server list --name ${cluster_prefix}-control --format json)
73+
74+
# Get unique server names to avoid duplicate cleanup
75+
UNIQUE_NAMES=$(echo "$CONTROL_SERVERS" | jq -r '.[].Name' | sort | uniq)
76+
for name in $UNIQUE_NAMES; do
77+
echo "Deleting cluster with control node: $name"
78+
79+
# Get the first matching server ID by name
80+
server=$(echo "$CONTROL_SERVERS" | jq -r '.[] | select(.Name=="'"$name"'") | .ID' | head -n1)
81+
82+
# Make sure server still exists (wasn't deleted earlier)
83+
if ! openstack server show "$server" &>/dev/null; then
84+
echo "Server $server no longer exists, skipping $name."
85+
continue
86+
fi
87+
88+
echo "Deleting cluster $cluster_prefix (server $server)..."
89+
./dev/delete-cluster.py $cluster_prefix --force
90+
done
91+
done
6892
shell: bash

0 commit comments

Comments
 (0)