Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase WOODPECKER_FORGE_TIMEOUT to fix config fetching for GitLab #4262

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/30-administration/10-server-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 3 additions & 2 deletions server/services/config/forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down