azure-sdk-for-go: Resource Group Create SDK should return an async poller - otherwise SDK users who create resources right after creating resource groups may see intermittent resource creation errors
Bug Report
Our Symptom
We are a team that runs frequent automated tests using the azure-sdk-for-go. Our test job does the following:
- Create a resource group in ARM
- Create a resource in that resource group in ARM
- Delete that resource in ARM
- Delete that resource group in ARM
Our tests recently started failing intermittently.
Based on our tests, we believe that ARM takes a few seconds for resource group creation to propagate in some cases and that those cases have recently become more common for us.
We have the following logs showing the calls we made to ARM:
| TIMESTAMP | operationName | httpMethod | httpStatusCode |
|---|---|---|---|
| 2023-09-19T01:49:53.3022402Z | PUT/SUBSCRIPTIONS/RESOURCEGROUPS/ | PUT | -1 |
| 2023-09-19T01:49:53.5115976Z | PUT/SUBSCRIPTIONS/RESOURCEGROUPS/ | PUT | 201 |
| 2023-09-19T01:49:53.5385677Z | PUT/SUBSCRIPTIONS/RESOURCEGROUPS/PROVIDERS/[REDACTED]/[REDACTED]/ | PUT | -1 |
| 2023-09-19T01:49:53.675967Z | PUT/SUBSCRIPTIONS/RESOURCEGROUPS/PROVIDERS/[REDACTED]/[REDACTED]/ | PUT | 404 |
| 2023-09-19T01:49:53.6893615Z | DELETE/SUBSCRIPTIONS/RESOURCEGROUPS/ | DELETE | -1 |
| 2023-09-19T01:49:53.7077024Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T01:49:53.7208683Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 200 |
| 2023-09-19T01:49:53.8012578Z | DELETE/SUBSCRIPTIONS/RESOURCEGROUPS/ | DELETE | 202 |
| 2023-09-19T01:49:57.5268868Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T01:49:57.5407255Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
| 2023-09-19T01:49:59.8134708Z | |||
| 2023-09-19T01:50:54.3947647Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T01:50:54.4134174Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
| 2023-09-19T01:50:58.6345241Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T01:50:58.6453696Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
| 2023-09-19T01:54:54.4810864Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T01:54:54.4928623Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
| 2023-09-19T01:54:57.8525784Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T01:54:57.8741165Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
| 2023-09-19T01:59:55.1376881Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T01:59:55.1507581Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
| 2023-09-19T01:59:56.3132961Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T01:59:56.3257017Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
| 2023-09-19T02:19:59.0603705Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T02:19:59.0735594Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
| 2023-09-19T02:49:54.5073409Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | -1 |
| 2023-09-19T02:49:54.5207871Z | GET/SUBSCRIPTIONS/RESOURCEGROUPS/ | GET | 404 |
The Problem in azure-sdk-for-go
Here’s the call signature for creation of a resource group in the track 2 azure-sdk-for-go from azresources.ResourceGroupsClient:
CreateOrUpdate(
ctx context.Context,
resourceGroupName string,
parameters azresources.ResourceGroup,
options *azresources.ResourceGroupsClientCreateOrUpdateOptions,
) (response azresources.ResourceGroupsClientCreateOrUpdateResponse, err error)
That type is simply a resource group:
// ResourceGroupsClientCreateOrUpdateResponse contains the response from method ResourceGroupsClient.CreateOrUpdate.
type ResourceGroupsClientCreateOrUpdateResponse struct {
// Resource group information.
ResourceGroup
}
This makes it easy for clients of the sdk to write code like this:
rg, err := resourceGroupClient.CreateOrUpdate(ctx, params.Name, azresources.ResourceGroup{
Location: to.Ptr(params.Location),
Name: to.Ptr(params.Name),
}, nil)
someOtherResource, err := resourceClient.CreateOrUpdate(ctx, params.Name, rg.Name, // other params)
However, this code will have some small chance of failing if ARM encounters the same delay we encountered. Customers of the SDK will go through a difficult and confusing troubleshooting process before either adding their own custom polling or a delay to their code like this:
rg, err := resourceGroupClient.CreateOrUpdate(ctx, params.Name, azresources.ResourceGroup{
Location: to.Ptr(params.Location),
Name: to.Ptr(params.Name),
}, nil)
time.Sleep(10 * time.Second)
someOtherResource, err := resourceClient.CreateOrUpdate(ctx, params.Name, rg.Name, // other params)
We added a custom poller to our code to get around this issue.
Can the resource group client be updated to return an async poller to reflect this delay and to avoid duplicating the troubleshooting we did?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (9 by maintainers)
@serbrech This fix did not work for us. We continue to see the issue with the correlation id set.
It looks like even with the correlation id being the same, it is possible for traffic to be routed to different regions in quick succession.
@serbrech I confirmed with ARM team that this behavior is currently expected.
I have reached out to the devs owning resource group. I’ll see what they say