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

Add warning log callback in client-go loading rules #117233

Merged
merged 3 commits into from May 24, 2023

Conversation

ardaguclu
Copy link
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

This provides a way to consumers use their own custom warning mechanisms instead default klog warning.

This PR takes over the previous good attempt #114793 to fix that issue.

Which issue(s) this PR fixes:

Fixes #94428

Special notes for your reviewer:

Does this PR introduce a user-facing change?

None

This provides a way to consumers use their own custom warning
mechanisms instead default klog warning.
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 12, 2023
@ardaguclu
Copy link
Member Author

/triage accepted
/priority backlog

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 12, 2023
@ardaguclu
Copy link
Member Author

/cc @yliaog

@ardaguclu
Copy link
Member Author

Since the previous attempt was reviewed by @yliaog, could you please take a look at this one?. Thanks.

@ardaguclu
Copy link
Member Author

As far as I can see, @yliaog hasn't been active for a while. @jpbetz @apelisse would you mind taking a look at this one?. Thanks.

@aojea
Copy link
Member

aojea commented May 18, 2023

/assign @liggitt

staging/src/k8s.io/client-go/tools/clientcmd/loader.go Outdated Show resolved Hide resolved

func (handler WarningHandler) Warn(message string) {
if handler == nil {
klog.V(1).Info(message)
Copy link
Member

Choose a reason for hiding this comment

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

what is the difference in output between klog.Warningf and klog.V(1).Info?

Copy link
Member Author

Choose a reason for hiding this comment

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

klog.Warning prints;

W0524 09:11:16.915498   42167 loader.go:142] Config not found:

klog.V(1).Info prints(only after --verbosity >= 1);

I0524 08:48:15.896816   40664 loader.go:142] Config not found:

staging/src/k8s.io/client-go/tools/clientcmd/loader.go Outdated Show resolved Hide resolved
@liggitt liggitt added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 24, 2023
@liggitt
Copy link
Member

liggitt commented May 24, 2023

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: b16e911e95d0a542efea7ab8ce900681289aff65

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, liggitt

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:

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 24, 2023
@ardaguclu
Copy link
Member Author

Thanks @liggitt. We are lucky that we have you for these portions of the code base.

@k8s-ci-robot k8s-ci-robot merged commit 2ea6896 into kubernetes:master May 24, 2023
10 of 12 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.28 milestone May 24, 2023
@ardaguclu ardaguclu deleted the warning-log-callback branch May 24, 2023 16:13
rayowang pushed a commit to rayowang/kubernetes that referenced this pull request Feb 9, 2024
* Add warning log callback in client-go loading rules

This provides a way to consumers use their own custom warning
mechanisms instead default klog warning.

* Use typed error instead plain string

* Fix interface change in unit test
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

client-go prints a klog warning by default in library code which is not allowed
4 participants