@@ -25,6 +25,7 @@ import (
2525 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2626 "k8s.io/apimachinery/pkg/runtime/schema"
2727 "k8s.io/apimachinery/pkg/watch"
28+ "k8s.io/client-go/rest"
2829 "k8s.io/client-go/tools/cache"
2930
3031 "github.com/argoproj/argo-cd/v2/controller/metrics"
@@ -394,6 +395,20 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e
394395 return nil , fmt .Errorf ("error getting custom label: %w" , err )
395396 }
396397
398+ clusterCacheConfig := cluster .RESTConfig ()
399+ // Controller dynamically fetches all resource types available on the cluster
400+ // using a discovery API that may contain deprecated APIs.
401+ // This causes log flooding when managing a large number of clusters.
402+ // https://github.com/argoproj/argo-cd/issues/11973
403+ // However, we can safely suppress deprecation warnings
404+ // because we do not rely on resources with a particular API group or version.
405+ // https://kubernetes.io/blog/2020/09/03/warnings/#customize-client-handling
406+ //
407+ // Completely suppress warning logs only for log levels that are less than Debug.
408+ if log .GetLevel () < log .DebugLevel {
409+ clusterCacheConfig .WarningHandler = rest.NoWarnings {}
410+ }
411+
397412 clusterCacheOpts := []clustercache.UpdateSettingsFunc {
398413 clustercache .SetListSemaphore (semaphore .NewWeighted (clusterCacheListSemaphoreSize )),
399414 clustercache .SetListPageSize (clusterCacheListPageSize ),
@@ -425,7 +440,7 @@ func (c *liveStateCache) getCluster(server string) (clustercache.ClusterCache, e
425440 clustercache .SetRetryOptions (clusterCacheAttemptLimit , clusterCacheRetryUseBackoff , isRetryableError ),
426441 }
427442
428- clusterCache = clustercache .NewClusterCache (cluster . RESTConfig () , clusterCacheOpts ... )
443+ clusterCache = clustercache .NewClusterCache (clusterCacheConfig , clusterCacheOpts ... )
429444
430445 _ = clusterCache .OnResourceUpdated (func (newRes * clustercache.Resource , oldRes * clustercache.Resource , namespaceResources map [kube.ResourceKey ]* clustercache.Resource ) {
431446 toNotify := make (map [string ]bool )
0 commit comments