diff --git a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go index 637569122a5..fae66455458 100644 --- a/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go @@ -75,6 +75,7 @@ func (db *AzureSqlDbManager) Ensure(ctx context.Context, obj runtime.Object, opt } if !helpers.ContainsString(ignore, azerr.Type) { instance.Status.Message = err.Error() + instance.Status.Provisioning = false return false, fmt.Errorf("AzureSqlDb GetDB error %v", err) } } @@ -84,19 +85,26 @@ func (db *AzureSqlDbManager) Ensure(ctx context.Context, obj runtime.Object, opt instance.Status.Message = err.Error() azerr := errhelp.NewAzureErrorAzureError(err) + // resource request has been sent to ARM + if azerr.Type == errhelp.AsyncOpIncompleteError { + instance.Status.Provisioning = true + return false, nil + } + // the errors that can arise during reconcilliation where we simply requeue catch := []string{ errhelp.ResourceGroupNotFoundErrorCode, errhelp.ParentNotFoundErrorCode, - errhelp.AsyncOpIncompleteError, } if helpers.ContainsString(catch, azerr.Type) { + instance.Status.Provisioning = false return false, nil } // assertion that a 404 error implies that the Azure SQL server hasn't been provisioned yet if resp != nil && resp.StatusCode == 404 { instance.Status.Message = fmt.Sprintf("Waiting for SQL Server %s to provision", server) + instance.Status.Provisioning = false return false, nil } diff --git a/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go b/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go index 2aa1c31ab2d..dc64bfb88df 100644 --- a/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go +++ b/pkg/resourcemanager/azuresql/azuresqlvnetrule/azuresqlvnetrule_reconcile.go @@ -6,7 +6,6 @@ package azuresqlvnetrule import ( "context" "fmt" - "strings" "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql" azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1" @@ -34,14 +33,12 @@ func (vr *AzureSqlVNetRuleManager) Ensure(ctx context.Context, obj runtime.Objec vnetrule, err := vr.GetSQLVNetRule(ctx, groupName, server, ruleName) if err == nil { - if vnetrule.VirtualNetworkRuleProperties != nil { - if vnetrule.VirtualNetworkRuleProperties.State == sql.Ready { - instance.Status.Provisioning = false - instance.Status.Provisioned = true - instance.Status.Message = resourcemanager.SuccessMsg - instance.Status.ResourceId = *vnetrule.ID - return true, nil - } + if vnetrule.VirtualNetworkRuleProperties != nil && vnetrule.VirtualNetworkRuleProperties.State == sql.Ready { + instance.Status.Provisioning = false + instance.Status.Provisioned = true + instance.Status.Message = resourcemanager.SuccessMsg + instance.Status.ResourceId = *vnetrule.ID + return true, nil } return false, nil } @@ -53,7 +50,8 @@ func (vr *AzureSqlVNetRuleManager) Ensure(ctx context.Context, obj runtime.Objec instance.Status.Message = err.Error() azerr := errhelp.NewAzureErrorAzureError(err) - if strings.Contains(azerr.Type, errhelp.AsyncOpIncompleteError) { + if azerr.Type == errhelp.AsyncOpIncompleteError { + instance.Status.Provisioning = true instance.Status.Message = "Resource request submitted to Azure successfully" return false, nil } @@ -63,11 +61,11 @@ func (vr *AzureSqlVNetRuleManager) Ensure(ctx context.Context, obj runtime.Objec errhelp.ParentNotFoundErrorCode, errhelp.ResourceNotFound, } - if helpers.ContainsString(ignorableErrors, azerr.Type) { instance.Status.Provisioning = false return false, nil } + return false, err }