Skip to content

Commit

Permalink
Merge pull request #3874 from ctripcloud/enable-cache-sync-timeout-on…
Browse files Browse the repository at this point in the history
…-fed

use ClusterCacheSyncTimeout for resources on fed control plane as well
  • Loading branch information
karmada-bot committed Aug 2, 2023
2 parents d916d87 + fad172d commit a2dc2e8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/agent/app/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func run(ctx context.Context, opts *options.Options) error {
workv1alpha1.SchemeGroupVersion.WithKind("Work").GroupKind().String(): opts.ConcurrentWorkSyncs,
clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").GroupKind().String(): opts.ConcurrentClusterSyncs,
},
CacheSyncTimeout: opts.ClusterCacheSyncTimeout.Duration,
},
NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
opts.DefaultTransform = fedinformer.StripUnusedFields
Expand Down
2 changes: 2 additions & 0 deletions cmd/controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func Run(ctx context.Context, opts *options.Options) error {
clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").GroupKind().String(): opts.ConcurrentClusterSyncs,
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) {
opts.DefaultTransform = fedinformer.StripUnusedFields
Expand Down Expand Up @@ -588,6 +589,7 @@ func startFederatedHorizontalPodAutoscalerController(ctx controllerscontext.Cont
ClusterScaleClientSetFunc: util.NewClusterScaleClientSet,
TypedInformerManager: typedmanager.GetInstance(),
RateLimiterOptions: ctx.Opts.RateLimiterOptions,
ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout,
}
if err = federatedHPAController.SetupWithManager(ctx.Mgr); err != nil {
return false, err
Expand Down
3 changes: 2 additions & 1 deletion pkg/controllers/federatedhpa/federatedhpa_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type FederatedHPAController struct {
RESTMapper meta.RESTMapper
EventRecorder record.EventRecorder
TypedInformerManager typedmanager.MultiClusterInformerManager
ClusterCacheSyncTimeout metav1.Duration

monitor monitor.Monitor

Expand Down Expand Up @@ -544,7 +545,7 @@ func (c *FederatedHPAController) buildPodInformerForCluster(clusterScaleClient *
c.TypedInformerManager.Start(clusterScaleClient.ClusterName)

if err := func() error {
synced := c.TypedInformerManager.WaitForCacheSyncWithTimeout(clusterScaleClient.ClusterName, util.CacheSyncTimeout)
synced := c.TypedInformerManager.WaitForCacheSyncWithTimeout(clusterScaleClient.ClusterName, c.ClusterCacheSyncTimeout.Duration)
if synced == nil {
return fmt.Errorf("no informerFactory for cluster %s exist", clusterScaleClient.ClusterName)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,5 @@ const (

const (
// CacheSyncTimeout refers to the time limit set on waiting for cache to sync
CacheSyncTimeout = 30 * time.Second
CacheSyncTimeout = 2 * time.Minute
)

0 comments on commit a2dc2e8

Please sign in to comment.