Skip to content

Commit

Permalink
sdk/client/resourcemanager: support for LROs which also return immedi…
Browse files Browse the repository at this point in the history
…ately

Both API Management/Schema @ 2021-08-01/2022-08-01 and Automation/DSCConfiguration@2020-01-13-preview
support returning both a LRO and an immediate response. In this case since we retrieve the original
URI and get a 200 OK /without/ a provisioningState header - we'll special-case this for now.

Fixes #542
  • Loading branch information
tombuildsstuff committed Aug 1, 2023
1 parent 72beed9 commit 28b3bca
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sdk/client/resourcemanager/poller_provisioning_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@ func (p *provisioningStatePoller) Poll(ctx context.Context) (*pollers.PollResult
status = string(result.Properties.ProvisioningState)
}
if status == "" {
return nil, fmt.Errorf("API didn't return either `provisioningState` or `status`")
// Some Operations support both an LRO and immediate completion, but _don't_ return a provisioningState field
// since we're checking for a 200 OK, if we didn't get a provisioningState field, for the moment we have to
// assume that we're done.
// Examples: `APIManagement` API Versions `2021-08-01` and `2022-08-01` - `Services.GlobalSchemaCreateOrUpdate`.
// Examples: `Automation` API Versions `2020-01-13-preview` - `DscNodeConfiguration.CreateOrUpdate`.
// https://github.com/hashicorp/go-azure-sdk/issues/542
return &pollers.PollResult{
PollInterval: p.initialRetryDuration,
Status: pollers.PollingStatusSucceeded,
}, nil
}

if strings.EqualFold(status, string(statusCanceled)) || strings.EqualFold(status, string(statusCancelled)) {
Expand Down

0 comments on commit 28b3bca

Please sign in to comment.