@@ -67,11 +67,31 @@ jobs:
67
67
for cluster_prefix in ${ci_clusters}
68
68
do
69
69
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
73
87
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
75
95
fi
76
96
done
77
97
shell : bash
0 commit comments