Skip to content

Commit

Permalink
Merge branch 'master' into keyvault-ctrl-hash256
Browse files Browse the repository at this point in the history
  • Loading branch information
cnadolny authored Mar 27, 2020
2 parents 641fe57 + 19155b1 commit 0d9c553
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
10 changes: 9 additions & 1 deletion pkg/resourcemanager/azuresql/azuresqldb/azuresqldb_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}

Expand Down

0 comments on commit 0d9c553

Please sign in to comment.