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 log level when failing to create pipeline #4107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fernandrone
Copy link
Contributor

Increase log level when failing to create pipelines. There are situations when woodpecker server may fail to create a pipeline and will only log the error under "debug", making it hard to debug the issue unless the user has explicitly activated debug logs.

To reproduce this, set the server environment variable WOODPECKER_CONFIG_SERVICE_ENDPOINT to an invalid service, i.e.

WOODPECKER_CONFIG_SERVICE_ENDPOINT: "http://invalid/config"

And it will fail to create a pipeline, but no error logs will be displayed, only a debug log:

{"level":"debug","repo":"<redacted>","error":"failed to fetch config via http (0) Post \"http://ci-template-plugin/config\": dial tcp: lookup invalid on 198.18.0.1:53: no such host","time":"2024-09-13T14:06:02Z","caller":"/go/src/github.com/woodpecker-ci/woodpecker/server/pipeline/create.go:90","message":"error while fetching config '' in 'refs/heads/fernandrone-patch-1' with user: 'fernandrone'"}

Increase verbosity of logs when failing to create pipelines. There are situations when woodpecker server may fail to create a pipeline and will only log the error under "debug", making it hard to debug the issue unless the user has explicitly activated debug logs.

To reproduce this, set the server environment variable WOODPECKER_CONFIG_SERVICE_ENDPOINT to an invalid service, i.e.

```
WOODPECKER_CONFIG_SERVICE_ENDPOINT: "http://invalid/config"
```

And it will fail to create a pipeline, but no error logs will be displayed, only a debug log:

```
{"level":"debug","repo":"<redacted>","error":"failed to fetch config via http (0) Post \"http://ci-template-plugin/config\": dial tcp: lookup invalid on 198.18.0.1:53: no such host","time":"2024-09-13T14:06:02Z","caller":"/go/src/github.com/woodpecker-ci/woodpecker/server/pipeline/create.go:90","message":"error while fetching config '' in 'refs/heads/fernandrone-patch-1' with user: 'fernandrone'"}
```
@fernandrone
Copy link
Contributor Author

I didn't open an issue given it's a trivial change. I couldn't find in past PRs if it was an explicit decision to leave logs as "debug" instead of "error" either.

return nil, updatePipelineWithErr(ctx, _forge, _store, pipeline, repo, repoUser, fmt.Errorf("could not load config from forge: %w", err))
}

pipelineItems, parseErr := parsePipeline(_forge, _store, pipeline, repoUser, repo, forgeYamlConfigs, nil)
if pipeline_errors.HasBlockingErrors(parseErr) {
log.Debug().Str("repo", repo.FullName).Err(parseErr).Msg("failed to parse yaml")
log.Error().Str("repo", repo.FullName).Err(parseErr).Msg("failed to parse yaml")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would not work well on public instance, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow. Something about the risk of someone flooding the logs?

Copy link
Contributor

@zc-devs zc-devs Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the risk of someone flooding the logs

Yes. While error on pulling config (whether config server / forge is misconfigured or network issues) is something admin copes with, pipeline syntax error is 'users' mistake.

HasBlockingErrors

It displays in UI, if I understand correctly. So, users see it and I as admin would probably not care (if would, then would set debug).

@qwerty287
Copy link
Contributor

I agree to @zc-devs and @fernandrone, you thumbed up the comment #4107 (comment), so I guess this can be closed?

@zc-devs
Copy link
Contributor

zc-devs commented Oct 6, 2024

this can be closed?

But I'm convinced in regards the first change.

log.Error().Str("repo", repo.FullName).Err(configFetchErr).Msgf("error while fetching config

Even message itself says, that it's error :)

Edit 1
Fernandrone's case is valid, error should be used.
Is there can be error while fetching config because of user's mistake/misconfiguration, not system issue? If yes, then this cases should be distinguished somehow and for system causes should be error level, for user mistakes - debug.

@qwerty287
Copy link
Contributor

You're right, this case - the config is not found in the repo - is handled separately. These logs only trigger if something really went wrong

@fernandrone
Copy link
Contributor Author

fernandrone commented Oct 6, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants