Skip to content

⚠ Improve logging by adopting contextual logging #3149

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

Merged
merged 2 commits into from
Mar 8, 2025

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Mar 8, 2025

Signed-off-by: Stefan Büringer buringerst@vmware.com

Follow-up to #3104 (comment)
Fixes #2987

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 8, 2025
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 8, 2025
@sbueringer
Copy link
Member Author

/assign @vincepri @alvaroaleman

@sbueringer sbueringer changed the title ⚠ Move to WatchErrorHandlerWithContext & HandleCrashWithLogger ⚠ Move to Informer.RunWithContext, WatchErrorHandlerWithContext & HandleCrashWithLogger Mar 8, 2025
…rashWithLogger

Signed-off-by: Stefan Büringer buringerst@vmware.com
@sbueringer sbueringer force-pushed the pr-adopt-ctx-logging branch from 85185e4 to eef257b Compare March 8, 2025 11:44
@sbueringer sbueringer changed the title ⚠ Move to Informer.RunWithContext, WatchErrorHandlerWithContext & HandleCrashWithLogger ⚠ Improve logging by moving to Informer.RunWithContext, WatchErrorHandlerWithContext & HandleCrashWithLogger Mar 8, 2025
@sbueringer
Copy link
Member Author

/cc @alexanderstephan

@k8s-ci-robot
Copy link
Contributor

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

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

In response to this:

/cc @alexanderstephan

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 8, 2025
@sbueringer sbueringer force-pushed the pr-adopt-ctx-logging branch from a591e40 to 9a7c585 Compare March 8, 2025 12:28
@sbueringer sbueringer changed the title ⚠ Improve logging by moving to Informer.RunWithContext, WatchErrorHandlerWithContext & HandleCrashWithLogger ⚠ Improve logging by adopting contextual logging Mar 8, 2025
@sbueringer
Copy link
Member Author

cc @pohly (just fyi)

@sbueringer
Copy link
Member Author

/retest

@sbueringer sbueringer force-pushed the pr-adopt-ctx-logging branch from 9a7c585 to 32fa5a8 Compare March 8, 2025 13:35
"sigs.k8s.io/controller-runtime/pkg/internal/syncs"
)

var log = logf.RuntimeLog.WithName("cache")
Copy link
Member

Choose a reason for hiding this comment

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

Obviously nothing to do with this change but we should stop hardcoding loggers like this and make them configurable (they can still default to something like this if unset ofc)

Copy link
Member Author

@sbueringer sbueringer Mar 9, 2025

Choose a reason for hiding this comment

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

Yeah. I was following existing patterns but I also don't like it.

Btw this logger uses the one from ctrl.SetLogger underneath.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 8, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: db55bae9ab0b2c4a6936eb882b80c29ade4d6fe4

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, sbueringer

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [alvaroaleman,sbueringer]

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 merged commit 0354f47 into kubernetes-sigs:main Mar 8, 2025
9 checks passed
@sbueringer sbueringer deleted the pr-adopt-ctx-logging branch March 10, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define own WatchErrorHandler for toolscache.Reflector
4 participants