Skip to content

Commit 9b1bf12

Browse files
authored
Update nightly-cleanup.yml
1 parent 37c1dce commit 9b1bf12

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

.github/workflows/nightly-cleanup.yml

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -63,43 +63,15 @@ jobs:
6363
echo "No clusters to delete."
6464
exit 0
6565
fi
66-
66+
6767
for cluster_prefix in ${ci_clusters}
6868
do
6969
echo "Processing cluster: $cluster_prefix"
70-
71-
# Retrieve all servers matching the cluster prefix
72-
SERVERS=$(openstack server list --name "${cluster_prefix}-.*" -f value -c ID -c Name)
73-
74-
if [[ -z "$SERVERS" ]]; then
75-
echo "No servers found for cluster ${cluster_prefix}"
76-
continue
77-
fi
78-
79-
KEEP_FLAG=false
80-
while IFS= read -r line; do
81-
SERVER_ID=$(echo "$line" | awk '{print $1}')
82-
SERVER_NAME=$(echo "$line" | awk '{print $2}')
83-
84-
# Check tags only on control nodes
85-
if [[ "$SERVER_NAME" == "${cluster_prefix}-control" ]]; then
86-
TAGS=$(openstack server show $SERVER_ID --column tags --format value)
87-
if [[ $TAGS =~ "keep" ]]; then
88-
echo "Skipping cluster ${cluster_prefix} - control instance is tagged as keep"
89-
KEEP_FLAG=true
90-
break
91-
fi
92-
fi
93-
done <<< "$SERVERS"
94-
95-
# Delete all servers if control node is not tagged with keep
96-
if [[ "$KEEP_FLAG" == false ]]; then
97-
echo "Deleting all servers in cluster ${cluster_prefix}"
98-
while IFS= read -r line; do
99-
SERVER_ID=$(echo "$line" | awk '{print $1}')
100-
echo "Deleting server $SERVER_ID"
101-
openstack server delete $SERVER_ID || true
102-
done <<< "$SERVERS"
70+
TAGS=$(openstack server show ${cluster_prefix}-control --column tags --format value)
71+
if [[ $TAGS =~ "keep" ]]; then
72+
echo "Skipping ${cluster_prefix} - control instance is tagged as keep"
73+
else
74+
./dev/delete-cluster.py ${cluster_prefix} --force
10375
fi
10476
done
10577
shell: bash

0 commit comments

Comments
 (0)