hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.56k stars 4.62k forks source link

azurerm_mssql_database times out converting to hyperscale #20793

Closed waylew-abc closed 1 year ago

waylew-abc commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.9

AzureRM Provider Version

3.45.0

Affected Resource(s)/Data Source(s)

azurerm_mssql_database

Terraform Configuration Files

resource "azurerm_mssql_database" "test" {
  name           = "hyperscale"
  server_id      = azurerm_mssql_server.server.id
  #collation      = "SQL_Latin1_General_CP1_CI_AS"
  license_type   = "LicenseIncluded"
  # dtu
  #sku_name = "S0"
  # hyperscale
  sku_name       = "HS_Gen5_4"
}

Debug Output/Panic Output

https://gist.github.com/waylew-abc/fcf19b98d4d1d0baacf2016ebdbd697a

Expected Behaviour

terraform should convert sku from 'S0' to hyperscale 'HS_Gen5_4' without timing out or throwing an error in azure resource activity log. this also occurs when tryin to destroy a converted hyperscale db

Actual Behaviour

apply eventually times out after 30 min and a 500 error with no cause appears in azure resource activity log

though terraform apply times out with server error. azure resource activity log indicates the upgrade was successful.

Steps to Reproduce

  1. create a new azure sql database with sku_mode="S0"
  2. run terraform apply terraform apply
  3. after 5 min, change to hyperscale 'sku_name= "HS_Gen5_4"`
  4. run terraform apply
  5. after time-out run terraform destroy

Important Factoids

No response

References

https://gist.github.com/waylew-abc/fcf19b98d4d1d0baacf2016ebdbd697a

sinbai commented 1 year ago

@waylew-abc thanks for opening this issue. I would like to explain that Terraform manages Azure resources by calling Azure Rest API. This seems to be an Azure API issue as in fact the error provided below is returned by Azure API not Terraform. For " throwing an error in azure resource activity log", Terraform also could not do anything as expected because the activity log was not generated by Terraform. Could you file an issue with Azure Rest API to see if it could help you?

 Error: waiting for create/update of Database: (Name "hyperscale" / Server Name "devops-panther" / Resource Group "devops-panther"): Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=401 -- Original Erro
r: Code="ExpiredAuthenticationToken" Message="The access token expiry UTC time '3/5/2023 7:51:16 PM' is earlier than current UTC time '3/5/2023 7:54:54 PM'."
manicminer commented 1 year ago

@waylew-abc Thanks for reporting this error. We fixed a bug relating to token refreshes in https://github.com/hashicorp/terraform-provider-azurerm/pull/20894 which will be released later today in v3.48.0. I believe this will resolve the error you are seeing. Accordingly, I'm going to close this issue and assign it to this week's milestone.

github-actions[bot] commented 1 year ago

This functionality has been released in v3.48.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 1 year ago

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.