@@ -67,11 +67,31 @@ jobs:
6767 for cluster_prefix in ${ci_clusters}
6868 do
6969 echo "Processing cluster: $cluster_prefix"
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"
70+ # Get all servers with the matching name for control node
71+ CONTROL_SERVERS=$(openstack server list --name ${cluster_prefix}-control --format json)
72+ SERVER_COUNT=$(echo "$CONTROL_SERVERS" | jq length)
73+
74+ if [[ $SERVER_COUNT -gt 1 ]]; then
75+ echo "Multiple servers found for control node '${cluster_prefix}-control'. Checking tags for each..."
76+
77+ for server in $(echo "$CONTROL_SERVERS" | jq -r '.[].ID'); do
78+ # Get tags for each control node
79+ TAGS=$(openstack server show "$server" --column tags --format value)
80+
81+ if [[ $TAGS =~ "keep" ]]; then
82+ echo "Skipping ${cluster_prefix} (server ${server}) - control instance is tagged as keep"
83+ else
84+ ./dev/delete-cluster.py ${cluster_prefix} --force
85+ fi
86+ done
7387 else
74- ./dev/delete-cluster.py ${cluster_prefix} --force
88+ # If only one server, extract its tags and proceed
89+ TAGS=$(echo "$CONTROL_SERVERS" | jq -r '.[0].Tags')
90+ if [[ $TAGS =~ "keep" ]]; then
91+ echo "Skipping ${cluster_prefix} - control instance is tagged as keep"
92+ else
93+ ./dev/delete-cluster.py ${cluster_prefix} --force
94+ fi
7595 fi
7696 done
7797 shell : bash
0 commit comments