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

⚠️ kube aware logger which could also work with logger.WithValues #1883

Closed
wants to merge 8 commits into from

Conversation

STRRL
Copy link
Contributor

@STRRL STRRL commented May 3, 2022

Signed-off-by: STRRL im@strrl.dev

This PR could fix #1290

As this comment says, the latest logr provide logr.Marshaler, it could be used instead the current "kube-aware-logger-things" implementation with custom zap encoder

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 3, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @STRRL!

It looks like this is your first PR to kubernetes-sigs/controller-runtime 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/controller-runtime has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 3, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @STRRL. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 3, 2022
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 3, 2022
@STRRL STRRL marked this pull request as ready for review May 3, 2022 10:33
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 3, 2022
@STRRL
Copy link
Contributor Author

STRRL commented May 3, 2022

Hi! I think this PR is ready for view.

/cc @timebertt

@k8s-ci-robot
Copy link
Contributor

@STRRL: GitHub didn't allow me to request PR reviews from the following users: timebertt.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

Hi! I think this PR is ready for view.

/cc @timebertt

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.

@STRRL
Copy link
Contributor Author

STRRL commented Jul 13, 2022

PTAL

/cc @FillZpp

"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)

var scheme = runtime.NewScheme()

func init() {
log.SetLogger(zap.New())
log.SetLogger(bootstrap.New())
Copy link
Member

Choose a reason for hiding this comment

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

It is a breaking change for those who are importing controller runtime.
Can you please use the emoji :warning: ?

Also, do we need to change the lib?

@@ -39,6 +39,7 @@ type NewEncoderFunc func(...EncoderConfigOption) zapcore.Encoder
// New returns a brand new Logger configured with Opts. It
// uses KubeAwareEncoder which adds Type information and
// Namespace/Name to the log.
// Deprecated: use bootstrap.New as instead.
Copy link
Member

@alvaroaleman alvaroaleman Jul 16, 2022

Choose a reason for hiding this comment

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

What is the reason for moving things around? If anyhow possible, lets avoid this. All existing projects will need to be updated to get this fix, that is something we absolutely want to avoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the reason for moving things around?

I think using zap as the package name might bring confusion to users because we actually do not use zap.Logger but logr.Logger.

As the controller-runtime still stay with 0.x.x, I think maybe it would be friendly to introduce breaking changes right now rather than bring breaking changes after the stable 1.x.x. ❤️

If anyhow possible, lets avoid this.

I would make it a try! :D

@alvaroaleman alvaroaleman added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 16, 2022
@alvaroaleman
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 16, 2022
@STRRL STRRL changed the title 🐛 kube aware logger which could also work with logger.WithValues ⚠️ 🐛 kube aware logger which could also work with logger.WithValues Jul 17, 2022
@STRRL STRRL changed the title ⚠️ 🐛 kube aware logger which could also work with logger.WithValues ⚠️ kube aware logger which could also work with logger.WithValues Jul 17, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 17, 2022
@STRRL STRRL force-pushed the kube-aware-logr-logger branch 2 times, most recently from da24bda to 521d348 Compare July 17, 2022 03:05
Signed-off-by: STRRL <im@strrl.dev>
@STRRL
Copy link
Contributor Author

STRRL commented Jul 17, 2022

Hi @alvaroaleman @camilamacedo86, I have updated the codes. It seems it would not change the API / bring the breaking changes now.

PTAL! ❤️

Could I remove the :warning: and change to use :bug: in the PR title?

@STRRL
Copy link
Contributor Author

STRRL commented Jul 17, 2022

And CGO_ENABLED=1 make test failed on my local machine with unrelated testcases, could I ignore them?

It definitely failed cause by these changes in this PR ... I am going to take a look.

Signed-off-by: STRRL <im@strrl.dev>
@STRRL
Copy link
Contributor Author

STRRL commented Jul 17, 2022

And CGO_ENABLED=1 make test failed on my local machine with unrelated testcases, could I ignore them?

It definitely failed cause by these changes in this PR ... I am going to take a look.

Fixed! PTAL! :D @alvaroaleman @camilamacedo86

@STRRL
Copy link
Contributor Author

STRRL commented Aug 8, 2022

Hi @alvaroaleman @camilamacedo86, PTAL ❤️

@STRRL
Copy link
Contributor Author

STRRL commented Aug 16, 2022

@STRRL
Copy link
Contributor Author

STRRL commented Oct 4, 2022

hi @alvaroaleman , could we push the progress of this PR

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2022
@zbindenren
Copy link
Contributor

Maybe we should wait a little with logger changes before we see what happens whit this proposal. It is likely going to be accepted.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: STRRL
Once this PR has been reviewed and has the lgtm label, please assign gerred for approval by writing /assign @gerred in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2022
@STRRL
Copy link
Contributor Author

STRRL commented Dec 6, 2022

Maybe we should wait a little with logger changes before we see what happens whit this proposal. It is likely going to be accepted.

It might still take a loooong time to use the new slog in the kubernetes ecosystem..

I am not sure it's worth waiting.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2023
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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
Copy link
Contributor

@STRRL: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-controller-runtime-test 0e3754a link true /test pull-controller-runtime-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 17, 2023
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 16, 2023
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logger.WithValues bypasses KubeAwareEncoder
6 participants