Increase WOODPECKER_FORGE_TIMEOUT to fix config fetching for GitLab (#4262)

This commit is contained in:
Patrick Schratz 2024-10-27 11:21:40 +01:00 committed by GitHub
parent 57f1d10c9b
commit 785f2e6d6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 4 deletions

View file

@ -287,7 +287,7 @@ var flags = append([]cli.Flag{
Sources: cli.EnvVars("WOODPECKER_FORGE_TIMEOUT"),
Name: "forge-timeout",
Usage: "how many seconds before timeout when fetching the Woodpecker configuration from a Forge",
Value: time.Second * 3,
Value: time.Second * 5,
},
&cli.UintFlag{
Sources: cli.EnvVars("WOODPECKER_FORGE_RETRY"),

View file

@ -484,7 +484,7 @@ Specify a configuration service endpoint, see [Configuration Extension](./40-adv
### `WOODPECKER_FORGE_TIMEOUT`
> Default: 3s
> Default: 5s
Specify timeout when fetching the Woodpecker configuration from forge. See <https://pkg.go.dev/time#ParseDuration> for syntax reference.

View file

@ -59,7 +59,7 @@ func (f *forgeFetcher) Fetch(ctx context.Context, forge forge.Forge, user *model
for i := 0; i < int(f.retryCount); i++ {
files, err = ffc.fetch(ctx, strings.TrimSpace(repo.Config))
if err != nil {
log.Trace().Err(err).Msgf("%d. try failed", i+1)
log.Trace().Err(err).Msgf("Attempt #%d failed", i+1)
}
if errors.Is(err, context.DeadlineExceeded) {
continue
@ -143,11 +143,12 @@ func (f *forgeFetcherContext) getFirstAvailableConfig(c context.Context, configs
for _, fileOrFolder := range configs {
if strings.HasSuffix(fileOrFolder, "/") {
// config is a folder
log.Trace().Msgf("fetching %s from forge", fileOrFolder)
files, err := f.forge.Dir(c, f.user, f.repo, f.pipeline, strings.TrimSuffix(fileOrFolder, "/"))
// if folder is not supported we will get a "Not implemented" error and continue
if err != nil {
if !(errors.Is(err, types.ErrNotImplemented) || errors.Is(err, &types.ErrConfigNotFound{})) {
log.Error().Err(err).Str("repo", f.repo.FullName).Str("user", f.user.Login).Msg("could not get folder from forge")
log.Error().Err(err).Str("repo", f.repo.FullName).Str("user", f.user.Login).Msgf("could not get folder from forge: %s", err)
forgeErr = append(forgeErr, err)
}
continue