You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#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.
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.
The text was updated successfully, but these errors were encountered:
@ash2k feel free to create a PR that copies the restCfg prior to setting that handler You can disable setting this in the client opts. Copying the config in the client creation and only setting it in the config would also make sense.
alvaroaleman
changed the title
Libraries should not modify globals as they do not and cannot see the big picture
Client creation globally sets a warning handler by default
Jun 14, 2022
alvaroaleman
changed the title
Client creation globally sets a warning handler by default
Client creation sets a global warning handler by default
Jun 14, 2022
#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.
controller-runtime/pkg/client/client.go
Lines 91 to 98 in 0c2effb
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.The text was updated successfully, but these errors were encountered: