Merge pull request #3874 from ctripcloud/enable-cache-sync-timeout-on-fed

use ClusterCacheSyncTimeout for resources on fed control plane as well
This commit is contained in:
karmada-bot 2023-08-02 11:24:44 +08:00 committed by GitHub
commit a2dc2e8bbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 2 deletions

View File

@ -197,6 +197,7 @@ func run(ctx context.Context, opts *options.Options) error {
workv1alpha1.SchemeGroupVersion.WithKind("Work").GroupKind().String(): opts.ConcurrentWorkSyncs, workv1alpha1.SchemeGroupVersion.WithKind("Work").GroupKind().String(): opts.ConcurrentWorkSyncs,
clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").GroupKind().String(): opts.ConcurrentClusterSyncs, clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").GroupKind().String(): opts.ConcurrentClusterSyncs,
}, },
CacheSyncTimeout: opts.ClusterCacheSyncTimeout.Duration,
}, },
NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
opts.DefaultTransform = fedinformer.StripUnusedFields opts.DefaultTransform = fedinformer.StripUnusedFields

View File

@ -150,6 +150,7 @@ func Run(ctx context.Context, opts *options.Options) error {
clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").GroupKind().String(): opts.ConcurrentClusterSyncs, clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").GroupKind().String(): opts.ConcurrentClusterSyncs,
schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Namespace"}.GroupKind().String(): opts.ConcurrentNamespaceSyncs, schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Namespace"}.GroupKind().String(): opts.ConcurrentNamespaceSyncs,
}, },
CacheSyncTimeout: opts.ClusterCacheSyncTimeout.Duration,
}, },
NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
opts.DefaultTransform = fedinformer.StripUnusedFields opts.DefaultTransform = fedinformer.StripUnusedFields
@ -588,6 +589,7 @@ func startFederatedHorizontalPodAutoscalerController(ctx controllerscontext.Cont
ClusterScaleClientSetFunc: util.NewClusterScaleClientSet, ClusterScaleClientSetFunc: util.NewClusterScaleClientSet,
TypedInformerManager: typedmanager.GetInstance(), TypedInformerManager: typedmanager.GetInstance(),
RateLimiterOptions: ctx.Opts.RateLimiterOptions, RateLimiterOptions: ctx.Opts.RateLimiterOptions,
ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout,
} }
if err = federatedHPAController.SetupWithManager(ctx.Mgr); err != nil { if err = federatedHPAController.SetupWithManager(ctx.Mgr); err != nil {
return false, err return false, err

View File

@ -68,6 +68,7 @@ type FederatedHPAController struct {
RESTMapper meta.RESTMapper RESTMapper meta.RESTMapper
EventRecorder record.EventRecorder EventRecorder record.EventRecorder
TypedInformerManager typedmanager.MultiClusterInformerManager TypedInformerManager typedmanager.MultiClusterInformerManager
ClusterCacheSyncTimeout metav1.Duration
monitor monitor.Monitor monitor monitor.Monitor
@ -544,7 +545,7 @@ func (c *FederatedHPAController) buildPodInformerForCluster(clusterScaleClient *
c.TypedInformerManager.Start(clusterScaleClient.ClusterName) c.TypedInformerManager.Start(clusterScaleClient.ClusterName)
if err := func() error { if err := func() error {
synced := c.TypedInformerManager.WaitForCacheSyncWithTimeout(clusterScaleClient.ClusterName, util.CacheSyncTimeout) synced := c.TypedInformerManager.WaitForCacheSyncWithTimeout(clusterScaleClient.ClusterName, c.ClusterCacheSyncTimeout.Duration)
if synced == nil { if synced == nil {
return fmt.Errorf("no informerFactory for cluster %s exist", clusterScaleClient.ClusterName) return fmt.Errorf("no informerFactory for cluster %s exist", clusterScaleClient.ClusterName)
} }

View File

@ -159,5 +159,5 @@ const (
const ( const (
// CacheSyncTimeout refers to the time limit set on waiting for cache to sync // CacheSyncTimeout refers to the time limit set on waiting for cache to sync
CacheSyncTimeout = 30 * time.Second CacheSyncTimeout = 2 * time.Minute
) )