Skip to content

Commit

Permalink
fix: Suppress API server warnings in clusterctl
Browse files Browse the repository at this point in the history
  • Loading branch information
dlipovetsky committed Jul 22, 2024
1 parent 53f0c53 commit 970898b
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 @@ -167,7 +167,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 970898b

Please sign in to comment.