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

Workaround for strange response code in recovery services network mappings API. Fixes issue #6026 #6747

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,6 +2,7 @@ package recoveryservices

import (
"fmt"
"net/http"
"time"

"github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-01-10/siterecovery"
Expand Down Expand Up @@ -106,7 +107,10 @@ func resourceArmSiteRecoveryNetworkMappingCreate(d *schema.ResourceData, meta in
if features.ShouldResourcesBeImported() && d.IsNewResource() {
existing, err := client.Get(ctx, fabricName, sourceNetworkName, name)
if err != nil {
if !utils.ResponseWasNotFound(existing.Response) {
if !utils.ResponseWasNotFound(existing.Response) &&
// todo this workaround can be removed when this bug is fixed
// https://github.com/Azure/azure-sdk-for-go/issues/8705
!utils.ResponseWasStatusCode(existing.Response, http.StatusBadRequest) {
return fmt.Errorf("Error checking for presence of existing site recovery network mapping %s (vault %s): %+v", name, vaultName, err)
}
}
Expand Down
Expand Up @@ -112,15 +112,15 @@ func testCheckAzureRMSiteRecoveryNetworkMappingExists(resourceName string) resou
if err != nil {
return err
}
networkName := id.Path["virtualNetworks"]
networkName := id.Path["virtualnetworks"]

client := acceptance.AzureProvider.Meta().(*clients.Client).RecoveryServices.NetworkMappingClient(resourceGroupName, vaultName)

// TODO Fix Bad: networkMapping error
resp, err := client.Get(ctx, fabricName, networkName, mappingName)
if err != nil {
if resp.Response.StatusCode == http.StatusNotFound {
return fmt.Errorf("Bad: networkMapping %q (network %q) does not exist", mappingName, networkName)
return fmt.Errorf("Bad: networkMapping %q (network %q, %q) does not exist", mappingName, networkName, networkId)
}

return fmt.Errorf("Bad: Get on networkMappingClient: %+v", err)
Expand Down