Skip to content

Commit

Permalink
Increase the number of retries for missing dates (#92)
Browse files Browse the repository at this point in the history
Internally, the existing timeouts are not always sufficient. Adjust the
retry loop to use exponential backoff with more attempts, resulting in a
total of 15s between the first and last attempts instead of the 3s in
the old implementation. Note that GitHub hooks have a 30s timeout, so we
can't go too much higher on the retry counts.
  • Loading branch information
bluekeyes authored Jun 24, 2019
1 parent 243eef8 commit b5eb561
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pull/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ const (
)

var (
commitLoadMaxAttempts = 3
commitLoadBaseDelay = time.Second
// 5 attempts, exponential 1000ms delay = 15s max wait
commitLoadMaxAttempts = 5
commitLoadBaseDelay = 1000 * time.Millisecond
)

// Locator identifies a pull request and optionally contains a full or partial
Expand Down Expand Up @@ -357,7 +358,7 @@ func (ghc *GitHubContext) loadCommits() ([]*Commit, error) {
if attempts >= commitLoadMaxAttempts {
return nil, errors.Errorf("head commit %.10s is missing pushed date; this is probably a bug", ghc.pr.HeadRefOID)
}
time.Sleep(time.Duration(attempts) * commitLoadBaseDelay)
time.Sleep(time.Duration(1<<uint(attempts-1)) * commitLoadBaseDelay)
}
}

Expand Down

0 comments on commit b5eb561

Please sign in to comment.