Skip to content

Commit 3d6038a

Browse files
committed
Updated delete script to be more careful
1 parent 4c2c5bb commit 3d6038a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.github/workflows/deploy-azure.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ jobs:
5151
./import_resources.sh
5252
5353
- name: Terraform Apply
54+
timeout-minutes: 120 # Increase timeout to 2 hours for AKS node pool operations
5455
run: |
5556
cd infra/azure
57+
# Set TF_PLUGIN_TIMEOUT to increase the timeout for Azure provider operations
58+
export TF_PLUGIN_TIMEOUT=120m
5659
terraform apply -auto-approve \
5760
-var="environment=${{ env.ENVIRONMENT }}" \
5861
-var="memgraph_username=${{ secrets.MEMGRAPH_USERNAME }}" \

infra/azure/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ resource "null_resource" "cleanup_unmanaged_resources" {
161161
set -e
162162
echo "Starting cleanup of unmanaged resources in ${data.azurerm_resource_group.github.name} resource group..."
163163
164+
# Check if there are any ongoing operations on the AKS cluster
165+
AKS_NAME="aks-ai-agent-${var.environment}"
166+
AKS_PROVISIONING_STATE=$(az aks show --name $AKS_NAME --resource-group ${data.azurerm_resource_group.github.name} --query "provisioningState" -o tsv 2>/dev/null || echo "NotFound")
167+
168+
if [[ "$AKS_PROVISIONING_STATE" != "Succeeded" && "$AKS_PROVISIONING_STATE" != "NotFound" ]]; then
169+
echo "AKS cluster is currently in $AKS_PROVISIONING_STATE state. Skipping cleanup to avoid conflicts."
170+
exit 0
171+
fi
172+
164173
# Get all resources in the resource group
165174
ALL_RESOURCES=$(az resource list --resource-group ${data.azurerm_resource_group.github.name} --query "[].id" -o tsv)
166175

0 commit comments

Comments
 (0)