mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-07-01 03:30:49 +00: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)
|
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
|
// 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 {
|
if err != nil {
|
||||||
logrus.Errorf("error: %s: cannot find %s in %s: %s", repo.FullName, repo.Config, build.Ref, err)
|
logrus.Errorf("error: %s: cannot find %s in %s: %s", repo.FullName, repo.Config, build.Ref, err)
|
||||||
c.AbortWithError(404, err)
|
c.AbortWithError(404, err)
|
||||||
|
|
Loading…
Reference in a new issue