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 fetch YAML #4107

Merged
merged 3 commits into from
Nov 28, 2024

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.

server/pipeline/create.go Outdated Show resolved Hide resolved
@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

@qwerty287
Copy link
Contributor

Updated the corresponding line, this should be ready now. @woodpecker-ci/maintainers please review

@qwerty287 qwerty287 changed the title Increase log level when failing to create pipeline Increase log level when failing to fetch YAML Nov 28, 2024
@qwerty287 qwerty287 requested a review from a team November 28, 2024 10:02
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 28.22%. Comparing base (45e3b48) to head (cabf8da).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
server/pipeline/create.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4107   +/-   ##
=======================================
  Coverage   28.22%   28.22%           
=======================================
  Files         385      385           
  Lines       27847    27847           
=======================================
  Hits         7860     7860           
  Misses      19296    19296           
  Partials      691      691           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qwerty287 qwerty287 merged commit 896e550 into woodpecker-ci:main Nov 28, 2024
8 of 9 checks passed
@woodpecker-bot
Copy link
Contributor

@woodpecker-bot woodpecker-bot mentioned this pull request Nov 28, 2024
1 task
@6543 6543 added server enhancement improve existing features labels Nov 28, 2024
@woodpecker-bot woodpecker-bot mentioned this pull request Dec 14, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve existing features server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants