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

refactor: Use new logrus.Logger instead of default #7193

Conversation

halvards
Copy link
Contributor

Use a new logrus.Logger instance instead of the default logrus singleton.

Relying on the default singleton is problematic when dependencies (or transitive dependencies) also use logrus. When code paths in these dependencies modify the default singleton, it also impacts Skaffold logging.

I ran into this issue while trying to upgrade the ko dependency to v0.10, and there was unwanted error-level log output messages from amazon-ecr-credential-helper.

Context:

This change also moves us closer to not leaking the logger implementation dependency outside the output/log package.

Tracking: #7131

Use a new logrus.Logger instance instead of the default logrus
singleton.

Relying on the default singleton is problematic when dependencies (or
transitive dependencies) also use logrus. When code paths in these
dependencies modify the default singleton, it also impacts Skaffold
logging.

I ran into this issue while trying to upgrade the `ko` dependency to
v0.10, and there was unwanted error-level log output messages from
`amazon-ecr-credential-helper`.

Context:
- ko-build/ko#586
- awslabs/amazon-ecr-credential-helper#309

This change also moves us closer to not leaking the logger
implementation dependency outside the `output/log` package.

Tracking: GoogleContainerTools#7131
@halvards halvards requested a review from a team as a code owner March 15, 2022 12:21
@halvards halvards requested a review from briandealwis March 15, 2022 12:21
}

// New returns a new logrus.Logger.
// We use a new instance instead of the default logrus singleton to avoid clashes with dependencies that also use logrus.
func New() *logrus.Logger {
return logrus.New()
}

// KanikoLogLevel makes sure kaniko logs at least at Info level and at most Debug level (trace doesn't work with Kaniko)
func KanikoLogLevel() logrus.Level {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function doesn't appear to be called anywhere, except for the unit test. I left the function signature unchanged, in case I missed something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we've actually been using the global logrus logger, but we should definitely completely move off of that. I can make a follow up to this to have us use a local one that we own

@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #7193 (c0b8c5d) into main (290280e) will decrease coverage by 1.99%.
The diff coverage is 56.96%.

@@            Coverage Diff             @@
##             main    #7193      +/-   ##
==========================================
- Coverage   70.48%   68.48%   -2.00%     
==========================================
  Files         515      560      +45     
  Lines       23150    26485    +3335     
==========================================
+ Hits        16317    18139    +1822     
- Misses       5776     7095    +1319     
- Partials     1057     1251     +194     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/deploy.go 52.00% <ø> (-1.85%) ⬇️
cmd/skaffold/app/cmd/dev.go 84.61% <0.00%> (ø)
cmd/skaffold/app/cmd/render.go 36.66% <0.00%> (-4.72%) ⬇️
cmd/skaffold/skaffold.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/inspect_tests.go 62.50% <14.28%> (-1.14%) ⬇️
cmd/skaffold/app/cmd/lsp.go 28.12% <28.12%> (ø)
cmd/skaffold/app/cmd/fix.go 68.85% <40.00%> (-7.62%) ⬇️
cmd/skaffold/app/cmd/lint.go 42.85% <42.85%> (ø)
cmd/skaffold/app/cmd/find_configs.go 48.88% <50.00%> (+0.24%) ⬆️
cmd/skaffold/app/skaffold.go 76.19% <70.00%> (-8.43%) ⬇️
... and 222 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@halvards halvards added the kokoro:run runs the kokoro jobs on a PR label Mar 15, 2022
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Mar 15, 2022
@briandealwis briandealwis requested review from MarlonGamez and removed request for briandealwis March 15, 2022 14:11
@briandealwis
Copy link
Member

Adding @MarlonGamez as he's our logging expert

Copy link
Contributor

@MarlonGamez MarlonGamez left a comment

Choose a reason for hiding this comment

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

thanks for making this change @halvards . As mentioned I can make a follow up to this to make further improvements

@MarlonGamez MarlonGamez merged commit a440214 into GoogleContainerTools:main Mar 16, 2022
halvards added a commit to halvards/skaffold that referenced this pull request Mar 23, 2022
The new `ko` build option to produce SBOM is disabled until we
have a design for how this should work across Skaffold builders.

Additional transitive dependencies (mainly authentication libraries
for various image registries) means that the Skaffold binary grows
by about 4.8MB.

Related: GoogleContainerTools#7193
Tracking: GoogleContainerTools#7131
halvards added a commit to halvards/skaffold that referenced this pull request Mar 24, 2022
The new `ko` build option to produce SBOM is disabled until we
have a design for how this should work across Skaffold builders.

Additional transitive dependencies (mainly authentication libraries
for various image registries) means that the Skaffold binary grows
by about 4.8MB.

The change to labels_test.go works around the tests failing due to
this change in `client-go` between `v0.21.3` and `v0.21.4`:
kubernetes/client-go@c6c0ca0
That commit came from this k/k PR:
kubernetes/kubernetes#102928

Related: GoogleContainerTools#7193
Tracking: GoogleContainerTools#7131
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants