Skip to content

Conversation

wallrj
Copy link
Member

@wallrj wallrj commented Nov 19, 2024

Ref: VC-33564

The aim of this PR is to filter out the warnings logged in client-go/tools/cache/reflector.go when a resource group version is not installed in the Kubernetes API server.
An example of such a warning, with --logging-format=json :

{"caller":"cache/reflector.go:561", "msg":"k8s.io/client-go@v0.31.1/tools/cache/reflector.go:243: failed to list cas-issuer.jetstack.io/v1beta1, Resource=googlecasissuers: the server could not find the requested resource", "ts":1.7320377905120225E12, "v":0}

ℹ️ When --logging-format=json the warning is actually logged as an info message, on stdout.
By default --logging-format=text in which case the warning is logged with a W prefix on stderr.

Hiding the warnings is achieved by creating a filtering logr.LogSink and assigning that to the default klog logger.

However it does not seem possible to maintain the correct file and line numbers when wrapping the logger this way.
I discussed this with the klog authors and they confirm that there are probably bugs in the way the klog functions unwrap the stack:

In that thread on Slack, I learned from the klog authors that there is an in progress PR which will remove this distracting warning message:

So I will close this PR.

Signed-off-by: Richard Wall <richard.wall@venafi.com>
@wallrj
Copy link
Member Author

wallrj commented Nov 20, 2024

I learned from the klog authors that there is an in progress PR which will remove this distracting warning message:

So I will close this PR.

@wallrj wallrj closed this Nov 20, 2024
@wallrj wallrj changed the title WIP: [VC-35738] Hide the client-go reflector warning logs [VC-35738] Hide the client-go reflector warning logs Nov 20, 2024
@wallrj wallrj deleted the VC-33564-suppress-reflector-logs branch November 20, 2024 11:02
@maelvls
Copy link
Member

maelvls commented Mar 14, 2025

Seems like controller-runtime already bumped client-go to v0.33.0-alpha.1, which contains the fix that removes the log line "the server could not find the requested resource". I'll open a PR to see if it does the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants