Skip to content

Commit

Permalink
Vnet provision -> false (#980)
Browse files Browse the repository at this point in the history
* first

* added error msg

* mel feedback

Co-authored-by: William Mortl <wmortl@Williams-MacBook-Pro.local>
  • Loading branch information
WilliamMortlMicrosoft and William Mortl authored Apr 23, 2020
1 parent 2d2d8ab commit 2194394
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions pkg/errhelp/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (
InternalServerError = "InternalServerError"
NetworkAclsValidationFailure = "NetworkAclsValidationFailure"
SubnetHasServiceEndpointWithInvalidServiceName = "SubnetHasServiceEndpointWithInvalidServiceName"
InvalidAddressPrefixFormat = "InvalidAddressPrefixFormat"
)

func NewAzureError(err error) error {
Expand Down
30 changes: 17 additions & 13 deletions pkg/resourcemanager/vnet/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"net/http"
"strings"

azurev1alpha1 "github.com/Azure/azure-service-operator/api/v1alpha1"
"github.com/Azure/azure-service-operator/pkg/errhelp"
Expand Down Expand Up @@ -37,15 +38,13 @@ func (g *AzureVNetManager) Ensure(ctx context.Context, obj runtime.Object, opts
// succeeded! end reconcilliation successfully
instance.Status.Provisioning = false
instance.Status.Provisioned = true
instance.Status.FailedProvisioning = false
instance.Status.Message = resourcemanager.SuccessMsg
instance.Status.ResourceId = *vNet.ID
return true, nil
}

instance.Status.Provisioning = true
instance.Status.Provisioned = false
instance.Status.FailedProvisioning = false

result, err := g.CreateVNet(
ctx,
location,
Expand All @@ -67,31 +66,36 @@ func (g *AzureVNetManager) Ensure(ctx context.Context, obj runtime.Object, opts
errhelp.ResourceGroupNotFoundErrorCode,
errhelp.ParentNotFoundErrorCode,
errhelp.NotFoundErrorCode,
errhelp.AsyncOpIncompleteError,
}
catchUnrecoverableErrors := []string{
errhelp.NetcfgInvalidIPAddressPrefix,
errhelp.NetcfgInvalidSubnet,
errhelp.NetcfgInvalidVirtualNetworkSite,
errhelp.InvalidCIDRNotation,
errhelp.InvalidRequestFormat,
errhelp.InvalidAddressPrefixFormat,
}
if helpers.ContainsString(catch, azerr.Type) {
switch azerr.Type {
case errhelp.AsyncOpIncompleteError:
instance.Status.Provisioning = true
}

// reconciliation is not done but error is acceptable
// everything ok - just requeue
if strings.Contains(azerr.Type, errhelp.AsyncOpIncompleteError) {
return false, nil
}
if helpers.ContainsString(catchUnrecoverableErrors, azerr.Type) {

// Unrecoverable error, so stop reconcilation
// reconciliation is not done but error is acceptable
if helpers.ContainsString(catch, azerr.Type) {
instance.Status.Provisioning = false
return true, nil
return false, nil
}

instance.Status.Provisioning = false

// Unrecoverable error, so stop reconcilation
if helpers.ContainsString(catchUnrecoverableErrors, azerr.Type) {
instance.Status.FailedProvisioning = true
instance.Status.Message = fmt.Sprintf("Reconcilation hit unrecoverable error: %s", errhelp.StripErrorIDs(err))
return true, nil
}

return false, fmt.Errorf("Error creating VNet: %s, %s - %v", resourceGroup, resourceName, err)
}

Expand Down

0 comments on commit 2194394

Please sign in to comment.