Skip to content

When client is configured to suppress API server warnings, warnings are still logged #2886

@dlipovetsky

Description

@dlipovetsky

In #1468, we added a client option to surface API server warnings. In fact, this PR made warnings surface by default.

Even though we wanted to surface warnings, we exposed this behavior using the SuppressWarnings option. By default, the option is disabled, and warnings are surfaced.

However, when the option is enabled, warnings are not suppressed. This is because client-go continues to log warnings using its default warning handler. This was probably not caught when the PR was reviewd, because at the time of the PR, client-go apparently suppressed warnings by default. Today, client-go does not suppress warnings by default.


Let's elicit a warning from the API server. I'll use the client to create a Custom Resource, and include an undefined field in the request. I won't enable strict field validation, so the API server will return a warning.

If suppression is disabled, stderr shows:

2024-07-23T15:47:09-07:00	INFO	KubeAPIWarningLogger	metadata.finalizers: "example": prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writers

If suppression is enabled, stderr shows:

W0723 15:47:16.022148 1030480 warnings.go:70] metadata.finalizers: "example": prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writers

I expect the warning not to show. However, it does show, because client-go's default warning handler runs.

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions