You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
az aks operation-abort --resource-group "$RG" --name "$AKS" --operation-id "$OP_ID" || echo "⚠️ Could not abort operation, may require manual intervention"
124
-
done
125
-
126
-
# Wait for all operations to complete or be aborted
127
-
echo "⏳ Waiting for operations to complete or be aborted..."
128
-
max_retries=20
129
-
retry_count=0
130
-
while [ $retry_count -lt $max_retries ]; do
131
-
ONGOING_COUNT=$(az aks operation list --resource-group "$RG" --name "$AKS" --query "length([?status=='Running' || status=='Pending'])" -o tsv)
132
-
if [ "$ONGOING_COUNT" -eq 0 ]; then
133
-
echo "✅ No more ongoing operations"
134
-
break
135
-
fi
136
-
echo "⏳ Still have $ONGOING_COUNT ongoing operations, waiting 15s... ($(($retry_count + 1))/$max_retries)"
137
-
sleep 15
138
-
retry_count=$((retry_count + 1))
139
-
done
140
-
141
-
if [ $retry_count -eq $max_retries ]; then
142
-
echo "::warning::Timed out waiting for operations to complete. This might cause Terraform to fail."
143
-
fi
144
-
else
145
-
echo "✅ No ongoing operations found"
146
-
fi
113
+
echo "🔍 Checking AKS cluster state..."
147
114
148
115
# Wait for the cluster to be in a Succeeded provisioning state
149
-
echo "⏳ Ensuring cluster is in a Succeeded state..."
150
-
max_retries=10
116
+
echo "⏳ Waiting for cluster to be in a stable state..."
117
+
max_retries=15
151
118
retry_count=0
119
+
152
120
while [ $retry_count -lt $max_retries ]; do
153
121
PROVISION_STATE=$(az aks show --resource-group "$RG" --name "$AKS" --query "provisioningState" -o tsv)
122
+
154
123
if [ "$PROVISION_STATE" = "Succeeded" ]; then
155
124
echo "✅ AKS cluster is in Succeeded state"
125
+
# Force a small delay to ensure all backend operations are truly complete
126
+
sleep 30
156
127
break
157
128
fi
129
+
158
130
echo "⏳ AKS state: $PROVISION_STATE, waiting 30s... ($(($retry_count + 1))/$max_retries)"
159
131
sleep 30
160
132
retry_count=$((retry_count + 1))
161
133
done
162
134
163
135
if [ $retry_count -eq $max_retries ]; then
164
-
echo "::warning::Timed out waiting for AKS to reach Succeeded state. This might cause Terraform to fail."
136
+
echo "::warning::Timed out waiting for AKS to reach Succeeded state."
137
+
echo "⚠️ Attempting to proceed anyway, but Terraform might fail."
165
138
fi
139
+
140
+
# Display detailed cluster information for debugging
141
+
echo "📊 Current AKS cluster status:"
142
+
az aks show --resource-group "$RG" --name "$AKS" --query "{provisioningState:provisioningState,powerState:powerState,kubernetesVersion:kubernetesVersion,nodeResourceGroup:nodeResourceGroup}" -o table || true
143
+
144
+
# This pause gives the system time to finalize any background operations
145
+
echo "⏱️ Allowing 60 seconds of stabilization time before proceeding..."
0 commit comments