Skip to content

Commit

Permalink
Adapt Throttling to Outscale API
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-mdr committed Dec 20, 2022
1 parent ca9e56d commit 6506640
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/drivers/outscale/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ var (
retry.RetryIf(isThrottlingError),
retry.LastErrorOnly(true),
}

// Throtlling
ThrottlingErrors = []int{503, 429}
)

func (d *OscDriver) waitForState(vmId string, state string) error {
Expand Down Expand Up @@ -78,8 +81,10 @@ func (d *OscDriver) waitForState(vmId string, state string) error {

func isThrottlingError(err error) bool {
if err != nil {
if strings.Contains(fmt.Sprint(err), "RequestLimitExceeded:") {
return true
for _, errorCode := range ThrottlingErrors {
if strings.Contains(errorCode, fmt.Sprint(err)) {
return true
}
}
}
return false
Expand All @@ -89,7 +94,6 @@ func cleanUp(d *OscDriver) {
d.Remove()
}


func extractApiError(err error) (bool, *osc.ErrorResponse) {
genericError, ok := err.(osc.GenericOpenAPIError)
if ok {
Expand All @@ -111,4 +115,4 @@ func getErrorInfo(err error, httpRes *http.Response) string {
}

return fmt.Sprintf("%v", err)
}
}

0 comments on commit 6506640

Please sign in to comment.