Skip to content

Client creation sets a global warning handler by default #1928

@ash2k

Description

@ash2k

#1468 introduced warning handling. Unfortunately, the code makes an assumption that it's the place in a program that has the authority to set global warning handlers. It's simply not true.

rest.SetDefaultWarningHandler(
log.NewKubeAPIWarningLogger(
logger,
log.KubeAPIWarningLoggerOptions{
Deduplicate: !options.Opts.AllowDuplicateLogs,
},
),
)

The code above shouldn't mess with globals, it should be done by the program's author in main() or something like that. The above code should only set warning handler on the provided config. And even that is questionable - if the caller wants, they can just configure that by themself, right? In the config they are providing and/or via the mentioned global. controller-runtime simply doesn't need to do anything, this code should be removed.

In my concrete situation I set warning handler in main() and it's overwritten by controller-runtime somewhere deep in the call stack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions