IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
341 stars 670 forks source link

VPC Load Balancer already exist after timeout creating #2769

Closed dprosper closed 2 years ago

dprosper commented 3 years ago

Community Note

Terraform CLI and Terraform IBM Provider Version

Using IBM Cloud Schematics: v0.14.11

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "ibm_is_lb" "lb" {
  name            = "${var.lb_name}-lb"
  subnets         = var.subnets
  resource_group  = var.resource_group_id
  type            = var.lb_type
  tags            = var.tags
  security_groups = [ibm_is_security_group.lb_sg.id]
}

Debug Output

Results from first Apply

 2021/06/22 12:14:56 Terraform apply | module.create_vpc[0].module.load_balancer_public.ibm_is_lb.lb: Still creating... [30m0s elapsed]
 2021/06/22 12:15:06 Terraform apply | 
 2021/06/22 12:15:06 Terraform apply | Error: timeout while waiting for state to become 'done, ' (last state: 'provisioning', timeout: 30m0s)
 2021/06/22 12:15:06 Terraform apply | 
 2021/06/22 12:15:06 Terraform apply |   on modules/create_vpc/lb/main.tf line 7, in resource "ibm_is_lb" "lb":
 2021/06/22 12:15:06 Terraform apply |    7: resource "ibm_is_lb" "lb" {
 2021/06/22 12:15:06 Terraform apply | 
 2021/06/22 12:15:06 Terraform apply | 
 2021/06/22 12:15:06 Terraform apply | 
 2021/06/22 12:15:06 Terraform apply | Error: timeout while waiting for state to become 'done, ' (last state: 'provisioning', timeout: 30m0s)
 2021/06/22 12:15:06 Terraform apply | 
 2021/06/22 12:15:06 Terraform apply |   on modules/create_vpc/lb/main.tf line 7, in resource "ibm_is_lb" "lb":
 2021/06/22 12:15:06 Terraform apply |    7: resource "ibm_is_lb" "lb" {
 2021/06/22 12:15:06 Terraform apply | 
 2021/06/22 12:15:06 Terraform apply | 

Results from second Apply

2021/06/22 13:19:55 Terraform apply | module.create_vpc[0].module.load_balancer_public.ibm_is_lb.lb: Creating...
 2021/06/22 13:19:55 Terraform apply | module.create_vpc[0].module.load_balancer_private.ibm_is_lb.lb: Creating...
 2021/06/22 13:19:58 Terraform apply | 
 2021/06/22 13:19:58 Terraform apply | Error: Error while creating Load Balancer err Name 'vpc-scaling-lb-public-lb' is used by another load balancer instance. Please choose a different name.
 2021/06/22 13:19:58 Terraform apply | {
 2021/06/22 13:19:58 Terraform apply |     "StatusCode": 400,
 2021/06/22 13:19:58 Terraform apply |     "Headers": {
 2021/06/22 13:19:58 Terraform apply |         "Cf-Cache-Status": [
 2021/06/22 13:19:58 Terraform apply |             "DYNAMIC"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Cf-Ray": [
 2021/06/22 13:19:58 Terraform apply |             "6635c565b87b4e3e-FRA"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Cf-Request-Id": [
 2021/06/22 13:19:58 Terraform apply |             "0ad579b39300004e3e0723a000000001"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Content-Length": [
 2021/06/22 13:19:58 Terraform apply |             "361"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Content-Type": [
 2021/06/22 13:19:58 Terraform apply |             "application/json; charset=utf-8"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Date": [
 2021/06/22 13:19:58 Terraform apply |             "Tue, 22 Jun 2021 13:19:58 GMT"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Expect-Ct": [
 2021/06/22 13:19:58 Terraform apply |             "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Server": [
 2021/06/22 13:19:58 Terraform apply |             "cloudflare"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Transaction-Id": [
 2021/06/22 13:19:58 Terraform apply |             "f1438a8a-385e-482b-b460-39e3e01d2d7e"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "Vary": [
 2021/06/22 13:19:58 Terraform apply |             "Accept-Encoding"
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "X-Request-Id": [
 2021/06/22 13:19:58 Terraform apply |             "f1438a8a-385e-482b-b460-39e3e01d2d7e"
 2021/06/22 13:19:58 Terraform apply |         ]
 2021/06/22 13:19:58 Terraform apply |     },
 2021/06/22 13:19:58 Terraform apply |     "Result": {
 2021/06/22 13:19:58 Terraform apply |         "errors": [
 2021/06/22 13:19:58 Terraform apply |             {
 2021/06/22 13:19:58 Terraform apply |                 "code": "load_balancer_duplicate_name",
 2021/06/22 13:19:58 Terraform apply |                 "message": "Name 'vpc-scaling-lb-public-lb' is used by another load balancer instance. Please choose a different name.",
 2021/06/22 13:19:58 Terraform apply |                 "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-rias-error-messagesload_balancer_duplicate_name",
 2021/06/22 13:19:58 Terraform apply |                 "target": {
 2021/06/22 13:19:58 Terraform apply |                     "name": "name",
 2021/06/22 13:19:58 Terraform apply |                     "type": "field"
 2021/06/22 13:19:58 Terraform apply |                 }
 2021/06/22 13:19:58 Terraform apply |             }
 2021/06/22 13:19:58 Terraform apply |         ],
 2021/06/22 13:19:58 Terraform apply |         "trace": "f1438a8a-385e-482b-b460-39e3e01d2d7e"
 2021/06/22 13:19:58 Terraform apply |     },
 2021/06/22 13:19:58 Terraform apply |     "RawResult": null
 2021/06/22 13:19:58 Terraform apply | }
 2021/06/22 13:19:58 Terraform apply | 
 2021/06/22 13:19:58 Terraform apply | 
 2021/06/22 13:19:58 Terraform apply |   on modules/create_vpc/lb/main.tf line 7, in resource "ibm_is_lb" "lb":
 2021/06/22 13:19:58 Terraform apply |    7: resource "ibm_is_lb" "lb" {
 2021/06/22 13:19:58 Terraform apply | 
 2021/06/22 13:19:58 Terraform apply | 
 2021/06/22 13:19:58 Terraform apply | 

Expected Behavior

After there was a timeout creating the resource, since the resource was still getting created, there should have been some state information stored in tfstate, i.e. the ID of the LB resources as there were available in the REST CLI and Cloud UI. The Terraform state should have that information so that the next apply would find them.

Actual Behavior

There was no information on the IDs of the LBs in the Terraform state, they were in create_pending state and not stored in the tfstate, at the next run Terraform tried to create them from scratch and it failed with the error seen above.

Steps to Reproduce

This is going to be difficult to reproduce since the LBs typically are created under 30 minutes, there was a system glitch that caused it to take more than 30 minutes and for the timeout to occur.

Important Factoids

References

kavya498 commented 2 years ago

@dprosper , Adding a terraform timeout block to extent creation timeout should help resolve this issue..

Reg Id: Resource creation is as follows:

There is nothing much we could do, as current code is already handling it.. Closing this issue for now. Kindly, open new issue and tag this issue, if you again encounter this issue..

Thanks.