Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/azurerm: Locking route table on subnet create/delete #13791

Merged
merged 6 commits into from
Apr 20, 2017

Conversation

whiskeyjay
Copy link
Contributor

@whiskeyjay whiskeyjay commented Apr 19, 2017

This fix is very similar to #13637 by @tombuildsstuff - a similar error (429) can happen if the route table is being updated while trying to create/delete a subnet that uses the said route table.

Also, added a check in the resource id parser for empty string key or value (this can happen from Import command as users can manually type in a resource id).

The following script can repro the error intermittently:

resource "azurerm_resource_group" "rtTableTests" {
    name = "acctestRG"
    location = "West US"
}

resource "azurerm_virtual_network" "rtTable2" {
    name = "acctestvirtnet"
    address_space = ["10.0.0.0/16"]
    location = "West US"
    resource_group_name = "${azurerm_resource_group.rtTableTests.name}"
    tags {
        environment = "Testing"
    }
}

resource "azurerm_subnet" "rtTable2" {
    name = "acctestsubnet"
    resource_group_name = "${azurerm_resource_group.rtTableTests.name}"
    virtual_network_name = "${azurerm_virtual_network.rtTable2.name}"
    address_prefix = "10.0.2.0/24"
        route_table_id = "${azurerm_route_table.rtTable2.id}"
}

resource "azurerm_route_table" "rtTable2" {
  name                = "rtTable2-RT"
  location            = "West US"
  resource_group_name = "${azurerm_resource_group.rtTableTests.name}"
}

resource "azurerm_route" "route_a" {
  name                = "TestRouteA"
  resource_group_name = "${azurerm_resource_group.rtTableTests.name}"
  route_table_name    = "${azurerm_route_table.rtTable2.name}"

  address_prefix         = "10.100.0.0/14"
  next_hop_type          = "VirtualAppliance"
  next_hop_in_ip_address = "10.10.1.1"
}

Error message is:

Failure responding to request: StatusCode=429 -- Original Error: autorest/azure: Service returned an error. Status=429 Code="RetryableError" Message="A retryable error occured." Details=[{"code":"ReferencedResourceNotProvisioned","message":"Cannot proceed with operation because resource /subscriptions/c3adb315-00d7-4bd0-96be-c96210ced312/resourceGroups/acctestRG/providers/Microsoft.Network/routeTables/rtTable2-RT used by resource /subscriptions/c3adb315-00d7-4bd0-96be-c96210ced312/resourceGroups/acctestRG/providers/Microsoft.Network/virtualNetworks/acctestvirtnet/subnets/acctestsubnet is not in Succeeded state. Resource is in Updating state and the last operation that updated/is updating the resource is PutRouteOperation."}]

Acc test results:

make testacc TEST=./builtin/providers/azurerm/ TESTARGS='-run=TestAccAzureRMSubnet_basic'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/04/19 16:19:50 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/azurerm/ -v -run=TestAccAzureRMSubnet_basic -timeout 120m
=== RUN   TestAccAzureRMSubnet_basic
--- PASS: TestAccAzureRMSubnet_basic (164.72s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm    164.735s
make testacc TEST=./builtin/providers/azurerm/ TESTARGS='-run=TestAccAzureRMSubnet_disappears'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/04/19 16:24:25 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/azurerm/ -v -run=TestAccAzureRMSubnet_disappears -timeout 120m
=== RUN   TestAccAzureRMSubnet_disappears
--- PASS: TestAccAzureRMSubnet_disappears (165.17s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm    165.184s

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @whiskeyjay

Thanks for this contribution - it LGTM :)

I noticed a minor issue when running the tests - where the TestAccAzureRMSubnet_importBasic test was failing due to the extra placeholders in the testAccAzureRMSubnet_basic string not being present; so I've pushed a commit to fix that, and now the tests pass as expected:

$ envchain azurerm make testacc TEST=./builtin/providers/azurerm/ TESTARGS='-run=TestAccAzureRMSubnet'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/04/20 12:15:31 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/azurerm/ -v -run=TestAccAzureRMSubnet -timeout 120m
=== RUN   TestAccAzureRMSubnet_importBasic
--- PASS: TestAccAzureRMSubnet_importBasic (188.28s)
=== RUN   TestAccAzureRMSubnet_basic
--- PASS: TestAccAzureRMSubnet_basic (189.03s)
=== RUN   TestAccAzureRMSubnet_disappears
--- PASS: TestAccAzureRMSubnet_disappears (185.91s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	563.241s
$ make testacc TEST=./builtin/providers/azurerm/ TESTARGS='-run=TestParseAzureResourceID'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/04/20 12:27:46 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/azurerm/ -v -run=TestParseAzureResourceID -timeout 120m
=== RUN   TestParseAzureResourceID
--- PASS: TestParseAzureResourceID (0.00s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	0.019s

Thanks!

@tombuildsstuff tombuildsstuff merged commit 1775d48 into hashicorp:master Apr 20, 2017
tombuildsstuff added a commit that referenced this pull request Apr 20, 2017
@whiskeyjay
Copy link
Contributor Author

@tombuildsstuff Good catch, thanks!

@ghost
Copy link

ghost commented Apr 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants