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:
commit
a2dc2e8bbb
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue