From fee43cbe27ed703e85751c10e6109874e2701904 Mon Sep 17 00:00:00 2001 From: Erin Corson Date: Wed, 25 Mar 2020 15:42:17 -0600 Subject: [PATCH] handle BadRequest errors more broadly as failed provisioning scenarios for rg --- .../resourcegroups/reconcile.go | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/resourcemanager/resourcegroups/reconcile.go b/pkg/resourcemanager/resourcegroups/reconcile.go index 343b3f8dc67..77a8cbc74ab 100644 --- a/pkg/resourcemanager/resourcegroups/reconcile.go +++ b/pkg/resourcemanager/resourcegroups/reconcile.go @@ -6,6 +6,7 @@ package resourcegroups import ( "context" "fmt" + "net/http" "github.com/Azure/azure-service-operator/api/v1alpha1" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" @@ -29,19 +30,22 @@ func (g *AzureResourceGroupManager) Ensure(ctx context.Context, obj runtime.Obje if err != nil { instance.Status.Provisioned = false instance.Status.Message = err.Error() + + // handle special cases that won't work without a change to spec + if group.StatusCode == http.StatusBadRequest { + instance.Status.Provisioning = false + return true, nil + } + return false, fmt.Errorf("ResourceGroup create error %v", err) } - if instance.Status.Provisioning { - instance.Status.Provisioned = true - instance.Status.Provisioning = false - instance.Status.Message = resourcemanager.SuccessMsg - } else { - instance.Status.Provisioned = false - instance.Status.Provisioning = true - } + instance.Status.Provisioned = true + instance.Status.Provisioning = false + instance.Status.Message = resourcemanager.SuccessMsg instance.Status.ResourceId = *group.ID + return true, nil }