Skip to content

Commit

Permalink
Merge pull request #583 from hashicorp/b/api-management-polling
Browse files Browse the repository at this point in the history
sdk/client/resourcemanager: support for LROs which also return immediately
  • Loading branch information
tombuildsstuff authored Aug 1, 2023
2 parents 72beed9 + 28b3bca commit 31cc039
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 31cc039

Please sign in to comment.