Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Handle VirtualNetworkRuleBadRequest error for VNetRule #1010

Merged
merged 4 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/errhelp/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const (
SubnetHasServiceEndpointWithInvalidServiceName = "SubnetHasServiceEndpointWithInvalidServiceName"
InvalidAddressPrefixFormat = "InvalidAddressPrefixFormat"
FeatureNotSupportedForEdition = "FeatureNotSupportedForEdition"
VirtualNetworkRuleBadRequest = "VirtualNetworkRuleBadRequest"
)

func NewAzureError(err error) error {
Expand Down
11 changes: 11 additions & 0 deletions pkg/resourcemanager/mysql/vnetrule/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func (vr *MySQLVNetRuleClient) Ensure(ctx context.Context, obj runtime.Object, o
return false, nil
}

fatalErr := []string{
errhelp.VirtualNetworkRuleBadRequest,
}
ignorableErrors := []string{
errhelp.ResourceGroupNotFoundErrorCode,
errhelp.ParentNotFoundErrorCode,
Expand All @@ -76,6 +79,14 @@ func (vr *MySQLVNetRuleClient) Ensure(ctx context.Context, obj runtime.Object, o
return false, nil
}

if helpers.ContainsString(fatalErr, azerr.Type) {
instance.Status.Message = azerr.Error()
instance.Status.Provisioning = false
instance.Status.Provisioned = false
instance.Status.FailedProvisioning = true
return true, nil
}

// this happens when we try to create the VNet rule and the server doesnt exist yet
errorString := err.Error()
if strings.Contains(errorString, "does not have the server") {
Expand Down
10 changes: 10 additions & 0 deletions pkg/resourcemanager/psql/vnetrule/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func (vr *PostgreSQLVNetRuleClient) Ensure(ctx context.Context, obj runtime.Obje
return false, nil
}

fatalErr := []string{
errhelp.VirtualNetworkRuleBadRequest,
}
ignorableErrors := []string{
errhelp.ResourceGroupNotFoundErrorCode,
errhelp.ParentNotFoundErrorCode,
Expand All @@ -77,6 +80,13 @@ func (vr *PostgreSQLVNetRuleClient) Ensure(ctx context.Context, obj runtime.Obje
instance.Status.Provisioning = false
return false, nil
}
if helpers.ContainsString(fatalErr, azerr.Type) {
instance.Status.Message = azerr.Error()
instance.Status.Provisioning = false
instance.Status.Provisioned = false
instance.Status.FailedProvisioning = true
return true, nil
}

// this happens when we try to create the VNet rule and the server doesnt exist yet
errorString := err.Error()
Expand Down
1 change: 0 additions & 1 deletion pkg/resourcemanager/vnet/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func (g *AzureVNetManager) Ensure(ctx context.Context, obj runtime.Object, opts
errhelp.InvalidRequestFormat,
errhelp.LocationNotAvailableForResourceType,
errhelp.InvalidAddressPrefixFormat,

}

// everything ok - just requeue
Expand Down