@@ -186,7 +186,8 @@ func NewStore(dbmanager db.Manager) Storer {
186186 }
187187
188188 // create informers factory, enable and assign required informers
189- infFactory := informers .NewSharedInformerFactoryWithOptions (store .k8sClient .Clientset , 10 * time .Second ,
189+ // Use 30 minutes resync period to reduce API server load
190+ infFactory := informers .NewSharedInformerFactoryWithOptions (store .k8sClient .Clientset , 30 * time .Minute ,
190191 informers .WithNamespace (corev1 .NamespaceAll ))
191192
192193 store .informers .Namespace = infFactory .Core ().V1 ().Namespaces ().Informer ()
@@ -243,15 +244,17 @@ func NewStore(dbmanager db.Manager) Storer {
243244
244245 // rainbond custom resource
245246 rainbondClient := k8s .Default ().RainbondClient
246- rainbondInformer := externalversions .NewSharedInformerFactoryWithOptions (rainbondClient , 10 * time .Second ,
247+ // Use 30 minutes resync period to reduce API server load
248+ rainbondInformer := externalversions .NewSharedInformerFactoryWithOptions (rainbondClient , 30 * time .Minute ,
247249 externalversions .WithNamespace (corev1 .NamespaceAll ))
248250 store .listers .HelmApp = rainbondInformer .Rainbond ().V1alpha1 ().HelmApps ().Lister ()
249251 store .informers .HelmApp = rainbondInformer .Rainbond ().V1alpha1 ().HelmApps ().Informer ()
250252 store .listers .ThirdComponent = rainbondInformer .Rainbond ().V1alpha1 ().ThirdComponents ().Lister ()
251253 store .informers .ThirdComponent = rainbondInformer .Rainbond ().V1alpha1 ().ThirdComponents ().Informer ()
252254 store .listers .ComponentDefinition = rainbondInformer .Rainbond ().V1alpha1 ().ComponentDefinitions ().Lister ()
253255 store .informers .ComponentDefinition = rainbondInformer .Rainbond ().V1alpha1 ().ComponentDefinitions ().Informer ()
254- store .informers .ComponentDefinition .AddEventHandlerWithResyncPeriod (componentdefinition .GetComponentDefinitionBuilder (), time .Second * 300 )
256+ // Use 0 to disable additional resync for ComponentDefinition
257+ store .informers .ComponentDefinition .AddEventHandlerWithResyncPeriod (componentdefinition .GetComponentDefinitionBuilder (), 0 )
255258 store .informers .Job = infFactory .Batch ().V1 ().Jobs ().Informer ()
256259 store .listers .Job = infFactory .Batch ().V1 ().Jobs ().Lister ()
257260 if store .k8sClient .K8SVersion .AtLeast (utilversion .MustParseSemantic ("v1.21.0" )) {
@@ -315,23 +318,25 @@ func NewStore(dbmanager db.Manager) Storer {
315318 }
316319
317320 store .informers .Namespace .AddEventHandler (store .nsEventHandler ())
318- store .informers .Deployment .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
319- store .informers .StatefulSet .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
320- store .informers .Job .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
321- store .informers .CronJob .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
322- store .informers .Pod .AddEventHandlerWithResyncPeriod (store .podEventHandler (), time .Second * 10 )
323- store .informers .Secret .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
324- store .informers .Service .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
325- store .informers .Ingress .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
326- store .informers .ConfigMap .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
327- store .informers .ReplicaSet .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
328- store .informers .Endpoints .AddEventHandlerWithResyncPeriod (epEventHandler , time .Second * 10 )
329- store .informers .Nodes .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
330- store .informers .StorageClass .AddEventHandlerWithResyncPeriod (store , time .Second * 300 )
331- store .informers .Claims .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
332- store .informers .Events .AddEventHandlerWithResyncPeriod (store .evtEventHandler (), time .Second * 10 )
333- store .informers .HorizontalPodAutoscaler .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
334- store .informers .ThirdComponent .AddEventHandlerWithResyncPeriod (store , time .Second * 10 )
321+ // Use 0 to disable additional resync, rely on factory resync period
322+ store .informers .Deployment .AddEventHandlerWithResyncPeriod (store , 0 )
323+ store .informers .StatefulSet .AddEventHandlerWithResyncPeriod (store , 0 )
324+ store .informers .Job .AddEventHandlerWithResyncPeriod (store , 0 )
325+ store .informers .CronJob .AddEventHandlerWithResyncPeriod (store , 0 )
326+ store .informers .Pod .AddEventHandlerWithResyncPeriod (store .podEventHandler (), 0 )
327+ store .informers .Secret .AddEventHandlerWithResyncPeriod (store , 0 )
328+ store .informers .Service .AddEventHandlerWithResyncPeriod (store , 0 )
329+
330+ store .informers .Ingress .AddEventHandlerWithResyncPeriod (store , 0 )
331+ store .informers .ConfigMap .AddEventHandlerWithResyncPeriod (store , 0 )
332+ store .informers .ReplicaSet .AddEventHandlerWithResyncPeriod (store , 0 )
333+ store .informers .Endpoints .AddEventHandlerWithResyncPeriod (epEventHandler , 0 )
334+ store .informers .Nodes .AddEventHandlerWithResyncPeriod (store , 0 )
335+ store .informers .StorageClass .AddEventHandlerWithResyncPeriod (store , 0 )
336+ store .informers .Claims .AddEventHandlerWithResyncPeriod (store , 0 )
337+ store .informers .Events .AddEventHandlerWithResyncPeriod (store .evtEventHandler (), 0 )
338+ store .informers .HorizontalPodAutoscaler .AddEventHandlerWithResyncPeriod (store , 0 )
339+ store .informers .ThirdComponent .AddEventHandlerWithResyncPeriod (store , 0 )
335340
336341 return store
337342}
0 commit comments