Avoid infinite task queue retries when trying to compute repo vintages

GitHub consistently returns a 500 for large repos, so assume that the first
commit is the repo creation date for them.
This commit is contained in:
Mihai Parparita 2020-05-03 10:55:30 -07:00
parent 438cb1fdac
commit 728faecd4f

View file

@ -70,8 +70,14 @@ func computeVintage(c context.Context, userId int, userLogin string, repoId int,
if response != nil && response.StatusCode == 409 {
// GitHub returns with a 409 when a repository is empty.
commits = make([]github.RepositoryCommit, 0)
} else if response != nil && response.StatusCode >= 500 {
// Avoid retries if GitHub can't load commits (this happens for repos
// like AOSiP-Devices/kernel_xiaomi_laurel_sprout, presumably because
// they have too many commits).
log.Warningf(c, "Could not load commits for repo %s (%d), not retrying: %s", *repo.FullName, repoId, err.Error())
commits = make([]github.RepositoryCommit, 0)
} else if err != nil {
log.Errorf(c, "Could not load commits for repo %s (%d): %s", *repo.FullName, repoId, err.Error())
log.Errorf(c, "Could not load commits for repo %s (%d), will retry: %s", *repo.FullName, repoId, err.Error())
return err
}