@@ -63,43 +63,15 @@ jobs:
63
63
echo "No clusters to delete."
64
64
exit 0
65
65
fi
66
-
66
+
67
67
for cluster_prefix in ${ci_clusters}
68
68
do
69
69
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
103
75
fi
104
76
done
105
77
shell : bash
0 commit comments