Skip to content

Commit

Permalink
Add IsSubnetworkMissingIPv6GCEError to User Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
panslava committed Jan 18, 2023
1 parent 3c6c110 commit 9a36888
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const (
)

var networkTierErrorRegexp = regexp.MustCompile(`The network tier of external IP is STANDARD|PREMIUM, that of Address must be the same.`)
var subnetworkMissingIPv6ErrorRegexp = regexp.MustCompile("Subnetwork does not have an internal IPv6 IP space which is required for IPv6 L4 ILB forwarding rules.")

// NetworkTierError is a struct to define error caused by User misconfiguration of Network Tier.
type NetworkTierError struct {
Expand Down Expand Up @@ -201,6 +202,10 @@ func IsInUsedByError(err error) bool {
return strings.Contains(apiErr.Message, "being used by")
}

func IsSubnetworkMissingIPv6GCEError(err error) bool {
return subnetworkMissingIPv6ErrorRegexp.MatchString(err.Error())
}

// IsNetworkTierMismatchGCEError checks if error is a GCE network tier mismatch for external IP
func IsNetworkTierMismatchGCEError(err error) bool {
return networkTierErrorRegexp.MatchString(err.Error())
Expand Down Expand Up @@ -237,7 +242,8 @@ func IsUserError(err error) bool {
return IsNetworkTierError(err) ||
IsIPConfigurationError(err) ||
IsInvalidLoadBalancerSourceRangesSpecError(err) ||
IsInvalidLoadBalancerSourceRangesAnnotationError(err)
IsInvalidLoadBalancerSourceRangesAnnotationError(err) ||
IsSubnetworkMissingIPv6GCEError(err)
}

// IsNotFoundError returns true if the resource does not exist
Expand Down

0 comments on commit 9a36888

Please sign in to comment.