Skip to content

Commit

Permalink
Add retry code for throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
liuri1205 authored and xiaozhu36 committed Apr 16, 2021
1 parent 958084c commit 4acd43e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions alicloud/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,19 @@ func NeedRetry(err error) bool {
if strings.Contains(*e.Message, "code: 500, 您已开通过") {
return false
}
if *e.Code == ServiceUnavailable || throttlingRegex.MatchString(*e.Code) {
if *e.Code == ServiceUnavailable || *e.Code == "Rejected.Throttling" || throttlingRegex.MatchString(*e.Code) {
return true
}
re := regexp.MustCompile("^code: 5[\\d]{2}")
return re.MatchString(*e.Message)
}

if e, ok := err.(*errors.ServerError); ok {
return e.ErrorCode() == ServiceUnavailable || throttlingRegex.MatchString(e.ErrorCode())
return e.ErrorCode() == ServiceUnavailable || e.ErrorCode() == "Rejected.Throttling" || throttlingRegex.MatchString(e.ErrorCode())
}

if e, ok := err.(*common.Error); ok {
return e.Code == ServiceUnavailable || throttlingRegex.MatchString(e.Code)
return e.Code == ServiceUnavailable || e.Code == "Rejected.Throttling" || throttlingRegex.MatchString(e.Code)
}

return false
Expand Down

0 comments on commit 4acd43e

Please sign in to comment.