sdk: add customize initial poll delay via ctx - #1325
Conversation
|
Instead of mutating the initial poll interval, the original issue is better to be addressed by refactoring the code of resources like NIC from:
to:
|
|
It's still possible to encounter operation conflict during polling stage, right? because polling means the operation is in progress
|
|
I don't think so, the polling (in most cases) is just a GET operation to an endpoint for querying the status of the in-progress operation. |
|
The creation of the resource is still in progress if poll is not done, so we can directly unlock just after the CreateOrUpdate call when it's a LRO, because it's still possible to encounter operation in conflict error out of the lock. |
magodo
left a comment
There was a problem hiding this comment.
You might be right. I thought the lock was introduced to avoid race condition of the initial DELETE request which is apparently not the case...
I've taken a look at the actual implementation and put down some comments.
| interval := DefaultPollingInterval | ||
| if retryAfter := retryAfterFromResponse(response); retryAfter != nil { | ||
| interval = *retryAfter | ||
| } | ||
| deletePoller, deletePollerErr := deletePollerFromResponse(response, client, interval) |
There was a problem hiding this comment.
Should this be part of the deletePollerFromResponse, just similar to longRunningOperationPollerFromResponse?
There was a problem hiding this comment.
because the interval is a input arg of deletePollerFromResponse, it would cause confusion if we change interval value inside the function. it is different from longRunningOperationPollerFromResponse which only has the response as the input parameter.
| return v | ||
| } | ||
| return 0 | ||
| } |
There was a problem hiding this comment.
With the change of hornoring the retry-after in deletePollerFromResponse, is this change still necessary for the issue reported?
Also, I don't know if using the context to change the initial delay (actually it might better to be called default retry duration as it can be used not only in the initial delay), another easier way might be to simply add a public method to mutate it similar to AllowRetryOnError().
There was a problem hiding this comment.
WithInitialPollingDelay is primarily used during the creation of the network interface resource to customize the initial delay. It is designed to modify only the initial polling delay, not the polling interval. The retry duration after the first poll is determined by the most recent poll result, which seems appropriate to me.
Community Note
Description
InitialPollingDelay in
ctxThe
DefaultPollingIntervalis 10 seconds and there is no way to customize it when the LRO response header doesn't contain theRetry-Afterheader. this may cause long waiting time for resources likeazurerm_netowork_interface: it has a/many lock[s] and may create many instances at one apply, but the LRO has no retry-after header and 10 seconds initial delay is too long, so this PR add aWithInitialPollingDelaymethod to customize the delay value.related issue: hashicorp/terraform-provider-azurerm#30365 the create of network interface LRO actually finished within 1 second, but because of the 10 second default initial delay and the locks cause sequential creation, the customer has to wait for a long time to complete. there was also an internal IcM ticket in MS about creating 100+ NIC in one apply.
delete poller honor the Retry-After header
The current delete poller always using
deletePollerwithDefaultPollingIntervalbut actually the DELETE response may contain the Retry-After header, this PR also add the logic to honor it, for example the delete ofazurerm_network_interfacesRetry-Aftervalue is 4.This is a (please select all that apply):
Related Issue(s)
Fixes #0000
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the provider.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Note
If this PR changes meaningfully during the course of review please update the title and description as required.