rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
263 stars 228 forks source link

[BUG] Error removing Cloud Credential #1088

Open principekiss opened 1 year ago

principekiss commented 1 year ago

Rancher Server Setup

Information about the Cluster

User Information

Provider Information

Describe the bug

On Terraform destroy, the rancher2_cloud_credential resource return an error intermittently:

Error removing Cloud Credential: Bad response statusCode [500]. Status [500 Internal Server Error]. Body: [baseType=error, code=ServerError, message=Index with name by-cloud-cred does not exist] from [https://rancher.lawliet.net/v3/cloudCredentials/cattle-global-data:cc-lxwhp]

When browsing the URL https://rancher.lawliet.net/v3/cloudCredentials/cattle-global-data:cc-lxwhp, the cloud credential exists.

If running multiple times the terraform destroy command, it finally gets deleted.

This bug appeared since Rancher v2.6.9.

To Reproduce

resource "rancher2_bootstrap" "admin" { provider = rancher2.bootstrap

initial_password  = random_password.rancher.result
password          = var.admin_password
telemetry         = false
token_update      = false

depends_on = [ helm_release.rancher, azurerm_dns_a_record.rancher ] }

provider "rancher2" { alias = "admin"

api_url    = rancher2_bootstrap.admin.url
token_key  = rancher2_bootstrap.admin.token
insecure   = true
timeout    = "600s"

}

- Create cloud credentials 

### Actual Result
rancher2 Terraform provider fail to remove the cloud credentials:

```sh
rancher2_cloud_credential.rancher: Destroying... [id=cattle-global-data:cc-lxwhp]
╷
│ Error: Error removing Cloud Credential: Bad response statusCode [500]. Status [500 Internal Server Error]. Body: [baseType=error, code=ServerError, message=Index with name by-cloud-cred does not exist] from [https://rancher.ines.kangaroot.net/v3/cloudCredentials/cattle-global-data:cc-lxwhp]

Expected Result

The cloud credentials destroyed successfully.

davidhrbac commented 1 year ago

Same here.

code-eg commented 1 year ago

This happens often for me as well, even in the Rancher UI it takes 3-4 retries for Rancher to actually delete a credential. This was so bad I had to rip out the Cloud Credential from my Terraform and re-use the same Cloud Credential for every cluster. Very frustrating experience.