Skip to content

Commit

Permalink
fix: Suppress API server warnings in clusterctl (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlipovetsky authored and dkoshkin committed Oct 9, 2024
1 parent 3cce0d9 commit 6754da8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/clusterctl/client/cluster/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,23 @@ func (k *proxy) NewClient(ctx context.Context) (client.Client, error) {
connectBackoff := newConnectBackoff()
if err := retryWithExponentialBackoff(ctx, connectBackoff, func(_ context.Context) error {
var err error
c, err = client.New(config, client.Options{Scheme: localScheme})
// FIXME https://jira.nutanix.com/browse/NCN-101602
// We want to suppress warnings, i.e. prevent them from being logged.
// The controller-runtime client does not override WarningHandler when SuppressWarning is true.
// The existing handler remains in effect. The warnings continue to be logged.
//
// To work around this controller-runtime bug, we:
// 1. Make the handler the "no-op" handler, and
config.WarningHandler = rest.NoWarnings{}
c, err = client.New(config,
client.Options{
Scheme: localScheme,
// 2. Configure the client to suppress warnings
WarningHandler: client.WarningHandlerOptions{
SuppressWarnings: true,
},
},
)
if err != nil {
return err
}
Expand Down

0 comments on commit 6754da8

Please sign in to comment.