Skip to content

Commit

Permalink
log error case when server returns with 429
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlindhe committed Sep 15, 2020
1 parent 580afa0 commit 39b4113
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (ca *Cagent) Run(outputFile *os.File, interrupt chan struct{}) {
if err == ErrHubTooManyRequests {
// for error code 429, wait 10 seconds and try again
retryIn = 10 * time.Second
log.Errorf("Run: hub is overloaded, retrying in %v", retryIn)
} else if err == ErrHubServerError {
// for error codes 5xx, wait for configured amount of time and try again
retryIn = time.Duration(ca.Config.OnHTTP5xxRetryInterval) * time.Second
Expand Down Expand Up @@ -312,6 +313,7 @@ func (ca *Cagent) RunHeartbeat(interrupt chan struct{}) {
if err == ErrHubTooManyRequests {
// for error code 429, wait 10 seconds and try again
retryIn = 10 * time.Second
log.Errorf("RunHeartbeat: hub is overloaded, retrying in %v", retryIn)
} else if err == ErrHubServerError {
// for error codes 5xx, wait for configured amount of time and try again
retryIn = time.Duration(ca.Config.OnHTTP5xxRetryInterval) * time.Second
Expand Down
1 change: 1 addition & 0 deletions pkg/csender/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (cs *Csender) GracefulSend() error {
if err == cagent.ErrHubTooManyRequests {
// for error code 429, wait 10 seconds and try again
retryIn = 10 * time.Second
log.Errorf("csender: hub is overloaded, retrying in %v", retryIn)
} else if err == cagent.ErrHubServerError {
// for error codes 5xx, wait for 2 seconds and try again
retryIn = retryInterval
Expand Down

0 comments on commit 39b4113

Please sign in to comment.