Skip to content

Commit e42f11f

Browse files
committed
Fix CI issues
* Fix destroy-cluster failing because of an unset var * Improve debugging of cleanup-expired-clusters.sh
1 parent 20a8f6d commit e42f11f

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

ci/images/ci-runner/hack/bin/cleanup-expired-clusters.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ is_cluster_expired() {
2424
}
2525

2626
destroy_expired_clusters() {
27+
expired_clusters=()
2728
mapfile -t clusters < <(rosa list clusters --region "$REGION" | grep "ready" | awk '{print $2}')
2829

30+
echo "[$(date +"%Y/%m/%d %H:%M:%S")] Cluster count: ${#clusters[@]}"
2931
for cluster in "${clusters[@]}"; do
3032
if [[ "${EXCLUDE_CLUSTER[*]}" =~ $cluster ]]; then
3133
continue
@@ -34,13 +36,21 @@ destroy_expired_clusters() {
3436
is_expired=$(is_cluster_expired "$cluster")
3537

3638
if [[ "$is_expired" == "true" ]]; then
37-
export CLUSTER_NAME="$cluster"
38-
"$SCRIPT_DIR"/destroy-cluster.sh
39+
expired_clusters+=( "$cluster" )
3940
fi
4041
done
42+
43+
echo "[$(date +"%Y/%m/%d %H:%M:%S")] Expired cluster count: ${#expired_clusters[@]}"
44+
count=0
45+
for cluster in "${expired_clusters[@]}"; do
46+
count=$(( count + 1 ))
47+
echo "Destroying $cluster [$count/${#expired_clusters[@]}]"
48+
export CLUSTER_NAME="$cluster"
49+
"$SCRIPT_DIR"/destroy-cluster.sh
50+
done
4151
}
4252

4353
setx_off
4454
rosa login --token="$ROSA_TOKEN"
4555
setx_on
46-
destroy_expired_clusters
56+
destroy_expired_clusters

ci/images/ci-runner/hack/bin/destroy-cluster.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if [ -e "$failure_file" ]; then
1717
echo "Delete '$failure_file' within 15 minutes to keep the cluster alive for investigation."
1818
echo
1919
echo "KUBECONFIG:"
20-
cat "$KUBECONFIG_DIR/$KUBECONFIG"
20+
cat "$KUBECONFIG_DIR/kubeconfig"
2121
echo
2222
echo "Connect to the ci-runner with: kubectl exec -n default --stdin --tty ci-runner -- bash"
2323
echo
@@ -35,7 +35,7 @@ fi
3535
source "$SCRIPT_DIR/utils.sh"
3636

3737
if [[ -n "$CLUSTER_NAME" ]]; then
38-
echo "Started to destroy cluster [$CLUSTER_NAME]..."
38+
echo "[$(date +"%Y/%m/%d %H:%M:%S")] Started to destroy cluster [$CLUSTER_NAME]..."
3939

4040
printf "Log in to your Red Hat account...\n" | indent 2
4141
setx_off
@@ -44,7 +44,8 @@ if [[ -n "$CLUSTER_NAME" ]]; then
4444

4545
rosa delete cluster --region "$REGION" --cluster="$CLUSTER_NAME" -y
4646
rosa logs uninstall --region "$REGION" --cluster="$CLUSTER_NAME" --watch
47-
4847
else
4948
echo "No OCP cluster need to be destroyed."
5049
fi
50+
51+
echo "[$(date +"%Y/%m/%d %H:%M:%S")] Done"

0 commit comments

Comments
 (0)