Skip to content

Commit 16d25f1

Browse files
committed
Correctly suppress API server warnings
1 parent a7baa23 commit 16d25f1

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

pkg/client/client.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,15 @@ func newClient(config *rest.Config, options Options) (*client, error) {
124124
config.UserAgent = rest.DefaultKubernetesUserAgent()
125125
}
126126

127-
if !options.WarningHandler.SuppressWarnings {
128-
// surface warnings
129-
logger := log.Log.WithName("KubeAPIWarningLogger")
130-
// Set a WarningHandler, the default WarningHandler
131-
// is log.KubeAPIWarningLogger with deduplication enabled.
132-
// See log.KubeAPIWarningLoggerOptions for considerations
133-
// regarding deduplication.
134-
config.WarningHandler = log.NewKubeAPIWarningLogger(
135-
logger,
136-
log.KubeAPIWarningLoggerOptions{
137-
Deduplicate: !options.WarningHandler.AllowDuplicateLogs,
138-
},
139-
)
127+
// By default, we de-duplicate and surface warnings.
128+
config.WarningHandler = log.NewKubeAPIWarningLogger(
129+
log.Log.WithName("KubeAPIWarningLogger"),
130+
log.KubeAPIWarningLoggerOptions{
131+
Deduplicate: !options.WarningHandler.AllowDuplicateLogs,
132+
},
133+
)
134+
if options.WarningHandler.SuppressWarnings {
135+
config.WarningHandler = rest.NoWarnings{}
140136
}
141137

142138
// Use the rest HTTP client for the provided config if unset

0 commit comments

Comments
 (0)