Azure / Azure/azure-rest-api-specs
[Mysql/FlexibleServer] The moment the programmatic creation is complete, the Get API returns that Mysql flexible server does not exist.
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 5.9k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 444
Description
Programmatically create Mysql Flexible Server in terraform using the [latest version 2021-05-01 API](https://github.com/Azure/azure-rest-api-specs/blob/bfa95078d6bb55687bec2c6ad78834deafd7c3fb/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/mysql.json#L42), then go through the Azure-Asyncoperation URL returned in the response to check the status of the operation. After getting the status is `Succeeded`, the [get API](https://github.com/Azure/azure-rest-api-specs/blob/bfa95078d6bb55687bec2c6ad78834deafd7c3fb/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/mysql.json#L213) returns that the Flexible Server does not exist. (It works well after sleeping 30 seconds after the operation is successful). The following information could prove this. Is it possible to fix the delayed ready issue of the API?
Step1: Send a request to create a flexibleServer.
```
2022/10/19 10:06:29 [DEBUG] AzureRM Request:
PUT /subscriptions/xxx/resourceGroups/acctestRG-mysql-221019094334184676/providers/Microsoft.DBforMySQL/flexibleServers/acctest-fs-221019094334184676?api-version=2021-05-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.18.4 (amd64-windows) go-autorest/v14.2.1 Azure-SDK-For-Go/v66.0.0 mysqlflexibleservers/2021-05-01 HashiCorp Terraform/1.2.9 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Length: 334
Content-Type: application/json; charset=utf-8
X-Ms-Authorization-Auxiliary:
X-Ms-Correlation-Request-Id: 753bef96-34bf-cf06-f226-15ad059efcb7
Accept-Encoding: gzip
{"location":"eastus","properties":{"administratorLogin":"_admin_Terraform_892123456789312","administratorLoginPassword":"QAZwsx123","availabilityZone":"1","backup":{"backupRetentionDays":7,"geoRedundantBackup":"Disabled"},"highAvailability":{"mode":"Disabled"},"network":{}},"sku":{"name":"Standard_B1s","tier":"Burstable"},"tags":{}}
2022/10/19 10:06:31 [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/xxx/resourceGroups/acctestRG-mysql-221019094334184676/providers/Microsoft.DBforMySQL/flexibleServers/acctest-fs-221019094334184676?api-version=2021-05-01:
HTTP/2.0 202 Accepted
Content-Length: 88
Azure-Asyncoperation: https://management.azure.com/subscriptions/xxx/providers/Microsoft.DBforMySQL/locations/eastus/azureAsyncOperation/4680c4b1-737a-44c8-b837-e40851b2a71b?api-version=2021-05-01
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Wed, 19 Oct 2022 02:06:30 GMT
Expires: -1
Location: https://management.azure.com/subscriptions/xxx/providers/Microsoft.DBforMySQL/locations/eastus/operationResults/4680c4b1-737a-44c8-b837-e40851b2a71b?api-version=2021-05-01
Pragma: no-cache
Retry-After: 60
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: 753bef96-34bf-cf06-f226-15ad059efcb7
X-Ms-Ratelimit-Remaining-Subscription-Writes: 1199
X-Ms-Request-Id: 4680c4b1-737a-44c8-b837-e40851b2a71b
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20221019T020630Z:c22d0ace-1167-47d8-80ce-789c2ed263cc
{"operation":"UpsertServerManagementOperationV2","startTime":"2022-10-19T02:06:30.513Z"}
```
Step2: Get the status of the azureAsyncOperation to wait for the creation to be ready.
```
2022/10/19 10:07:31 [DEBUG] AzureRM Request:
GET /subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/providers/Microsoft.DBforMySQL/locations/eastus/azureAsyncOperation/4680c4b1-737a-44c8-b837-e40851b2a71b?api-version=2021-05-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.18.4 (amd64-windows) go-autorest/v14.2.1 Azure-SDK-For-Go/v66.0.0 mysqlflexibleservers/2021-05-01 HashiCorp Terraform/1.2.9 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
X-Ms-Authorization-Auxiliary:
X-Ms-Correlation-Request-Id: 753bef96-34bf-cf06-f226-15ad059efcb7
Accept-Encoding: gzip
2022/10/19 10:07:32 [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/providers/Microsoft.DBforMySQL/locations/eastus/azureAsyncOperation/4680c4b1-737a-44c8-b837-e40851b2a71b?api-version=2021-05-01:
HTTP/2.0 200 OK
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Wed, 19 Oct 2022 02:07:31 GMT
Expires: -1
Pragma: no-cache
Retry-After: 60
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: 753bef96-34bf-cf06-f226-15ad059efcb7
X-Ms-Ratelimit-Remaining-Subscription-Reads: 11997
X-Ms-Request-Id: 80bf00fd-87f5-4535-bb82-797612392d21
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20221019T020731Z:4af3ecd0-ce3d-4d26-9d4e-80bfc352275a
{"name":"4680c4b1-737a-44c8-b837-e40851b2a71b","status":"InProgress","startTime":"2022-10-19T02:06:30.513Z"}
```
Step3: Repeatedly get the status of azureAsyncOperation util the status is "Succeeded".
```
...
...
...
2022/10/19 10:25:51 [DEBUG] AzureRM Request:
GET /subscriptions/xxx/providers/Microsoft.DBforMySQL/locations/eastus/azureAsyncOperation/4680c4b1-737a-44c8-b837-e40851b2a71b?api-version=2021-05-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.18.4 (amd64-windows) go-autorest/v14.2.1 Azure-SDK-For-Go/v66.0.0 mysqlflexibleservers/2021-05-01 HashiCorp Terraform/1.2.9 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
X-Ms-Authorization-Auxiliary:
X-Ms-Correlation-Request-Id: 753bef96-34bf-cf06-f226-15ad059efcb7
Accept-Encoding: gzip
2022/10/19 10:25:52 [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/xxx/providers/Microsoft.DBforMySQL/locations/eastus/azureAsyncOperation/4680c4b1-737a-44c8-b837-e40851b2a71b?api-version=2021-05-01:
HTTP/2.0 200 OK
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Wed, 19 Oct 2022 02:25:50 GMT
Expires: -1
Pragma: no-cache
Retry-After: 60
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: 753bef96-34bf-cf06-f226-15ad059efcb7
X-Ms-Ratelimit-Remaining-Subscription-Reads: 11979
X-Ms-Request-Id: 8f621f0c-1c7c-4551-85fc-ae73d9d29eb6
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20221019T022551Z:b28fc1c3-615f-488a-a10c-95930a839407
{"name":"4680c4b1-737a-44c8-b837-e40851b2a71b","status":"**Succeeded**","startTime":"2022-10-19T02:06:30.513Z"}
```
Step4: The "ResourceNotFound" error occurs when getting the Flexible Servers by API.( No error if sleeping for 30 seconds before this step)
```
2022/10/19 10:26:02 [DEBUG] AzureRM Request:
GET /subscriptions/xxx/resourceGroups/acctestRG-mysql-221019094334184676/providers/Microsoft.DBforMySQL/flexibleServers/acctest-fs-221019094334184676?api-version=2021-05-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.18.4 (amd64-windows) go-autorest/v14.2.1 Azure-SDK-For-Go/v66.0.0 mysqlflexibleservers/2021-05-01 HashiCorp Terraform/1.2.9 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
X-Ms-Authorization-Auxiliary:
X-Ms-Correlation-Request-Id: 753bef96-34bf-cf06-f226-15ad059efcb7
Accept-Encoding: gzip
2022/10/19 10:26:02 [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/xxx/resourceGroups/acctestRG-mysql-221019094334184676/providers/Microsoft.DBforMySQL/flexibleServers/acctest-fs-221019094334184676?api-version=2021-05-01:
HTTP/2.0 404 Not Found
Content-Length: 272
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Wed, 19 Oct 2022 02:26:01 GMT
Expires: -1
Pragma: no-cache
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: 753bef96-34bf-cf06-f226-15ad059efcb7
X-Ms-Failure-Cause: gateway
X-Ms-Request-Id: 97a4babf-22e4-4646-a3bf-cb09dce8e001
X-Ms-Routing-Request-Id: SOUTHEASTASIA:20221019T022601Z:97a4babf-22e4-4646-a3bf-cb09dce8e001
{"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.DBforMySQL/flexibleServers/acctest-fs-221019094334184676' under resource group 'acctestRG-mysql-221019094334184676' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}
```
Contributor guide
Research direction
Start with the linked specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/mysql.json, especially the create and Get API definitions. Reproduce the Azure-AsyncOperation sequence and the 404 immediately after Succeeded, then determine whether this repository can address the behavior. Done means the delayed-read case is addressed in the specification or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, mysql, terraform
- Domain
- api, cloud, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100