Skip to content

Commit c1ca755

Browse files
committed
fix(perf): use resourceVersion=0 for faster informer initialization
Set resourceVersion=0 in informer ListOptions to use API server's watch cache instead of etcd for initial list operations. This speeds up informer initialization when there are large numbers of Application resources.
1 parent c34d44a commit c1ca755

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

server/server.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,16 @@ func NewServer(ctx context.Context, opts ArgoCDServerOpts, appsetOpts Applicatio
310310
if len(opts.ApplicationNamespaces) > 0 {
311311
appInformerNs = ""
312312
}
313-
projFactory := appinformer.NewSharedInformerFactoryWithOptions(opts.AppClientset, 0, appinformer.WithNamespace(opts.Namespace), appinformer.WithTweakListOptions(func(_ *metav1.ListOptions) {}))
314-
appFactory := appinformer.NewSharedInformerFactoryWithOptions(opts.AppClientset, 0, appinformer.WithNamespace(appInformerNs), appinformer.WithTweakListOptions(func(_ *metav1.ListOptions) {}))
313+
// Set resourceVersion=0 for faster initial list from API server cache instead of etcd
314+
tweakListOptionsForFastInit := func(options *metav1.ListOptions) {
315+
// resourceVersion=0 means use API server's watch cache (faster but may be slightly stale)
316+
// This speeds up initial informer sync, especially with large numbers of Applications
317+
if options.ResourceVersion == "" {
318+
options.ResourceVersion = "0"
319+
}
320+
}
321+
projFactory := appinformer.NewSharedInformerFactoryWithOptions(opts.AppClientset, 0, appinformer.WithNamespace(opts.Namespace), appinformer.WithTweakListOptions(tweakListOptionsForFastInit))
322+
appFactory := appinformer.NewSharedInformerFactoryWithOptions(opts.AppClientset, 0, appinformer.WithNamespace(appInformerNs), appinformer.WithTweakListOptions(tweakListOptionsForFastInit))
315323

316324
projInformer := projFactory.Argoproj().V1alpha1().AppProjects().Informer()
317325
projLister := projFactory.Argoproj().V1alpha1().AppProjects().Lister().AppProjects(opts.Namespace)

0 commit comments

Comments
 (0)