Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_cosmosdb_account: ignore 500 responses from CheckNameExists() call #3747

Merged
merged 5 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion azurerm/resource_arm_cosmosdb_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ func resourceArmCosmosDbAccountCreate(d *schema.ResourceData, meta interface{})

r, err := client.CheckNameExists(ctx, name)
if err != nil {
return fmt.Errorf("Error checking if CosmosDB Account %q already exists (Resource Group %q): %+v", name, resourceGroup, err)
// todo remove when https://github.com/Azure/azure-sdk-for-go/issues/5157 is fixed
if !utils.ResponseWasStatusCode(r, 500) {
katbyte marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("Error checking if CosmosDB Account %q already exists (Resource Group %q): %+v", name, resourceGroup, err)
}
}
if !utils.ResponseWasNotFound(r) {
return fmt.Errorf("CosmosDB Account %s already exists, please import the resource via terraform import", name)
Expand Down
4 changes: 2 additions & 2 deletions azurerm/utils/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func ResponseWasNotFound(resp autorest.Response) bool {
return responseWasStatusCode(resp, http.StatusNotFound)
return ResponseWasStatusCode(resp, http.StatusNotFound)
}

func ResponseErrorIsRetryable(err error) bool {
Expand All @@ -26,7 +26,7 @@ func ResponseErrorIsRetryable(err error) bool {
return false
}

func responseWasStatusCode(resp autorest.Response, statusCode int) bool { // nolint: unparam
func ResponseWasStatusCode(resp autorest.Response, statusCode int) bool { // nolint: unparam
if r := resp.Response; r != nil {
if r.StatusCode == statusCode {
return true
Expand Down