From 2ee265b62c51cfe8218395ea9c02bf4125120196 Mon Sep 17 00:00:00 2001 From: Abhinav Dahiya Date: Thu, 12 Sep 2019 18:56:09 -0700 Subject: [PATCH] data/data/azure/bootstrap: ensure pool is only updated after machine is terminated It looks like an internal Azure race is causing a cryptic message like ``` Error: Error waiting for removal of Backend Address Pool Association for NIC \"ci-op-8qv3w054-282fe-2222c-bootstrap-nic\" (Resource Group \"ci-op-8qv3w054-282fe-2222c-rg\"): Code=\"OperationNotAllowed\" Message=\"Operation 'startTenantUpdate' is not allowed on VM 'ci-op-8qv3w054-282fe-2222c-bootstrap' since the VM is marked for deletion. You can only retry the Delete operation (or wait for an ongoing one to complete).\" Details=[] ``` when we update the NIC and the machine attached to it. `azurerm_network_interface_backend_address_pool_association.` depends on NIC but is not related to the machine NIC is attached to, the VM might be shutting down while this update is happeninig. This depends_on makes sure that VM is destroyed before we try to delete this association, preventing the race. Similar error seen by people like https://github.com/Azure/azure-rest-api-specs/issues/7207 --- data/data/azure/bootstrap/main.tf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/data/data/azure/bootstrap/main.tf b/data/data/azure/bootstrap/main.tf index 7adc0def9ad..87d77b68e12 100644 --- a/data/data/azure/bootstrap/main.tf +++ b/data/data/azure/bootstrap/main.tf @@ -144,6 +144,11 @@ resource "azurerm_virtual_machine" "bootstrap" { enabled = true storage_uri = var.storage_account.primary_blob_endpoint } + + depends_on = [ + azurerm_network_interface_backend_address_pool_association.public_lb_bootstrap, + azurerm_network_interface_backend_address_pool_association.internal_lb_bootstrap + ] } resource "azurerm_network_security_rule" "bootstrap_ssh_in" {