mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-29 18:04:15 +02:00
use a backoff when fetching the yaml
This commit is contained in:
parent
6397395570
commit
970080e444
@ -154,3 +154,18 @@ func Refresh(c context.Context, u *model.User) (bool, error) {
|
||||
}
|
||||
return refresher.Refresh(u)
|
||||
}
|
||||
|
||||
// FileBackoff fetches the file using an exponential backoff.
|
||||
// TODO replace this with a proper backoff
|
||||
func FileBackoff(remote Remote, u *model.User, r *model.Repo, b *model.Build, f string) (out []byte, err error) {
|
||||
for i := 0; i < 5; i++ {
|
||||
select {
|
||||
case <-time.After(time.Second * time.Duration(i)):
|
||||
out, err = remote.File(u, r, b, f)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ func PostHook(c *gin.Context) {
|
||||
}
|
||||
|
||||
// fetch the build file from the database
|
||||
confb, err := remote_.File(user, repo, build, repo.Config)
|
||||
confb, err := remote.FileBackoff(remote_, user, repo, build, repo.Config)
|
||||
if err != nil {
|
||||
logrus.Errorf("error: %s: cannot find %s in %s: %s", repo.FullName, repo.Config, build.Ref, err)
|
||||
c.AbortWithError(404, err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user