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

Why two different log packages? #1269

Closed
jaypipes opened this issue Dec 17, 2019 · 8 comments · Fixed by #1326
Closed

Why two different log packages? #1269

jaypipes opened this issue Dec 17, 2019 · 8 comments · Fixed by #1326
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.

Comments

@jaypipes
Copy link

I'm wondering why the manager's main.go uses the sigs.k8s.io/controller-runtime/pkg/log/zap library:

"sigs.k8s.io/controller-runtime/pkg/log/zap"

the webhook generator uses the sigs.k8s.io/controller-runtime/pkg/log package as well:

logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"

but the controller uses the github.com/go-logr/logr library:

"github.com/go-logr/logr"

Would it be beneficial to standardize on a single package?

/triage support

@jaypipes jaypipes added the kind/support Categorizes issue or PR as a support question. label Dec 17, 2019
@DirectXMan12
Copy link
Contributor

I'm wondering why the manager's main.go uses the sigs.k8s.io/controller-runtime/pkg/log/zap library:

pkg/log/zap is a helper for setting up logr with Zap. Logr is a generic logging interface. Zap is one concrete implementation.

the webhook generator uses the sigs.k8s.io/controller-runtime/pkg/log package as well

pkg/log is a helper for cases where you haven't plumbed through a copy of logr.Logger and want a handle to a semi-global logger

That being said, it's actually using pkg/runtime/log, which is a deprecated path. Not sure how that snuck into v2. cc @mengqiy

but the controller uses the github.com/go-logr/logr library:

Right. Most things should try to just pass down a copy of logr.Logger when they can. When they can't, they can fall back to pkg/log if they need to. Since the webhook code doesn't have its own struct to store the logger in, it has to use the global logger for the moment.

@DirectXMan12
Copy link
Contributor

/good-first-issue

on the replacement of pkg/runtime/log for pkg/log in just the v2 scaffolding.

@k8s-ci-robot
Copy link
Contributor

@DirectXMan12:
This request has been marked as suitable for new contributors.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-good-first-issue command.

In response to this:

/good-first-issue

on the replacement of pkg/runtime/log for pkg/log in just the v2 scaffolding.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jan 7, 2020
@jaypipes
Copy link
Author

jaypipes commented Jan 8, 2020

Thanks very much for the background @DirectXMan12! :) I'll try to hop on this contribution early next week.

@mengqiy
Copy link
Member

mengqiy commented Jan 10, 2020

@jaypipes That's a bug got snuck in.
Thanks for catching and trying to fix it! Feel free to assign me when you have the PR.

@dionysius
Copy link

dionysius commented Jan 14, 2020

Confirm that as well with staticcheck (golanci-lint) we should move from pkg/runtime/log to pkg/log

api/v1/sampleresource_webhook.go:6:2: SA1019: Package sigs.k8s.io/controller-runtime/pkg/runtime/log is deprecated: use pkg/log  (staticcheck)
        logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"

@mengqiy mengqiy added kind/bug Categorizes issue or PR as related to a bug. and removed kind/support Categorizes issue or PR as a support question. labels Jan 17, 2020
@mengqiy
Copy link
Member

mengqiy commented Jan 17, 2020

It seems no PR has been opened to fix the bug.
@camilamacedo86 Do you have bandwidth to fix this bug? It should be a straightforward one.

@camilamacedo86
Copy link
Member

/assign @camilamacedo86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants