X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f79d1cdf7696a3bbcc374df5ce4d1761a28a5ea5..b541c9d898d3dde983de2e0ea80a40e17d4c9b9f:/lib/cloud/ec2/ec2.go diff --git a/lib/cloud/ec2/ec2.go b/lib/cloud/ec2/ec2.go index 9a3f784b51..6251f18df0 100644 --- a/lib/cloud/ec2/ec2.go +++ b/lib/cloud/ec2/ec2.go @@ -13,6 +13,7 @@ import ( "encoding/json" "fmt" "math/big" + "regexp" "strconv" "strings" "sync" @@ -713,6 +714,8 @@ func isErrorQuota(err error) bool { return false } +var reSubnetSpecificInvalidParameterMessage = regexp.MustCompile(`(?ms).*( subnet |sufficient free [Ii]pv[46] addresses).*`) + // isErrorSubnetSpecific returns true if the problem encountered by // RunInstances might be avoided by trying a different subnet. func isErrorSubnetSpecific(err error) bool { @@ -724,7 +727,12 @@ func isErrorSubnetSpecific(err error) bool { return strings.Contains(code, "Subnet") || code == "InsufficientInstanceCapacity" || code == "InsufficientVolumeCapacity" || - code == "Unsupported" + code == "Unsupported" || + // See TestIsErrorSubnetSpecific for examples of why + // we look for substrings in code/message instead of + // only using specific codes here. + (strings.Contains(code, "InvalidParameter") && + reSubnetSpecificInvalidParameterMessage.MatchString(aerr.Message())) } // isErrorCapacity returns true if the error indicates lack of