Skip to content

Commit

Permalink
SCALRCORE-26173 - Terraform provider > clients > handle rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
soltysss committed May 31, 2023
1 parent de97838 commit e4cd75d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@ export SCALR_TOKEN=
You can run the acceptance tests like this:
```
make test
```
To run specific test:
```
TESTARGS="-run TestAccessPoliciesList/without_list_options" make test
```
7 changes: 7 additions & 0 deletions scalr.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -265,6 +266,12 @@ func (c *Client) retryHTTPCheck(ctx context.Context, resp *http.Response, err er
return c.retryServerErrors, err
}
if resp.StatusCode == 429 || (c.retryServerErrors && resp.StatusCode >= 500) {
if resp.StatusCode == 429 {
log.Printf(
"[DEBUG] API rate limit reached for %s%s, retrying...",
resp.Request.URL.Host, resp.Request.URL.Path,
)
}
return true, nil
}
return false, nil
Expand Down

0 comments on commit e4cd75d

Please sign in to comment.