Skip to content

Commit

Permalink
Retry if release-manager timeout (#27)
Browse files Browse the repository at this point in the history
* Add retry

* Change for loop to range and use slice

Co-authored-by: Bjørn <[email protected]>

* Shorten retry wait times

Co-authored-by: Ham the Astrochimp <[email protected]>
Co-authored-by: Bjørn <[email protected]>
  • Loading branch information
3 people authored Oct 2, 2020
1 parent ca9f0a0 commit 790d9e8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions issue_release_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"net/http"
"strings"
"time"

"github.com/google/go-github/v32/github"
"github.com/palantir/go-githubapp/githubapp"
Expand Down Expand Up @@ -173,6 +174,17 @@ func retrieveFromReleaseManager(endpoint string, authToken string, output interf
req.Header.Add("Authorization", "Bearer "+authToken)

resp, err := httpClient.Do(req)
// Retry 4 times if error
if err != nil {
waitTimesSec := []int{1, 2, 5, 10}
for _, seconds := range waitTimesSec {
time.Sleep(time.Duration(seconds) * time.Second) // Sleep waitTimesSec seconds
resp, err = httpClient.Do(req)
if err == nil {
return nil
}
}
}
if err != nil {
return errors.Wrap(err, "sending HTTP request")
}
Expand Down

0 comments on commit 790d9e8

Please sign in to comment.