From c178261ee48a682b681dc9998b5fbf86d4ff2fd1 Mon Sep 17 00:00:00 2001 From: jackcui Date: Fri, 5 Dec 2025 11:25:15 +0800 Subject: [PATCH] fix: Avoid resetting resourceVersion for watch. Fixes #15106 Signed-off-by: jackcui --- workflow/controller/controller.go | 5 ++++- .../informer/tolerant_cluster_workflow_template_informer.go | 5 ++++- .../informer/tolerant_workflow_template_informer.go | 5 ++++- workflow/controller/taskresult.go | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/workflow/controller/controller.go b/workflow/controller/controller.go index 22333fc96d4b..7fa61f9c46b1 100644 --- a/workflow/controller/controller.go +++ b/workflow/controller/controller.go @@ -851,7 +851,10 @@ func (wfc *WorkflowController) tweakListRequestListOptions(options *metav1.ListO options.LabelSelector = labelSelector.String() // `ResourceVersion=0` does not honor the `limit` in API calls, which results in making significant List calls // without `limit`. For details, see https://github.com/argoproj/argo-workflows/pull/11343 - options.ResourceVersion = "" + // Check if ResourceVersion is "0" and reset it to empty string to ensure proper pagination behavior + if options.ResourceVersion == "0" { + options.ResourceVersion = "" + } } func (wfc *WorkflowController) tweakWatchRequestListOptions(options *metav1.ListOptions) { diff --git a/workflow/controller/informer/tolerant_cluster_workflow_template_informer.go b/workflow/controller/informer/tolerant_cluster_workflow_template_informer.go index b603f0cfeec9..92e9c0f9deef 100644 --- a/workflow/controller/informer/tolerant_cluster_workflow_template_informer.go +++ b/workflow/controller/informer/tolerant_cluster_workflow_template_informer.go @@ -24,7 +24,10 @@ func NewTolerantClusterWorkflowTemplateInformer(dynamicInterface dynamic.Interfa return &tolerantClusterWorkflowTemplateInformer{delegate: dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynamicInterface, defaultResync, "", func(options *metav1.ListOptions) { // `ResourceVersion=0` does not honor the `limit` in API calls, which results in making significant List calls // without `limit`. For details, see https://github.com/argoproj/argo-workflows/pull/11343 - options.ResourceVersion = "" + // Check if ResourceVersion is "0" and reset it to empty string to ensure proper pagination behavior + if options.ResourceVersion == "0" { + options.ResourceVersion = "" + } }).ForResource(schema.GroupVersionResource{Group: workflow.Group, Version: workflow.Version, Resource: workflow.ClusterWorkflowTemplatePlural})} } diff --git a/workflow/controller/informer/tolerant_workflow_template_informer.go b/workflow/controller/informer/tolerant_workflow_template_informer.go index 21c89636dfe5..eb7b37ce677d 100644 --- a/workflow/controller/informer/tolerant_workflow_template_informer.go +++ b/workflow/controller/informer/tolerant_workflow_template_informer.go @@ -24,7 +24,10 @@ func NewTolerantWorkflowTemplateInformer(dynamicInterface dynamic.Interface, def return &tolerantWorkflowTemplateInformer{delegate: dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynamicInterface, defaultResync, namespace, func(options *metav1.ListOptions) { // `ResourceVersion=0` does not honor the `limit` in API calls, which results in making significant List calls // without `limit`. For details, see https://github.com/argoproj/argo-workflows/pull/11343 - options.ResourceVersion = "" + // Check if ResourceVersion is "0" and reset it to empty string to ensure proper pagination behavior + if options.ResourceVersion == "0" { + options.ResourceVersion = "" + } }).ForResource(schema.GroupVersionResource{Group: workflow.Group, Version: workflow.Version, Resource: workflow.WorkflowTemplatePlural})} } diff --git a/workflow/controller/taskresult.go b/workflow/controller/taskresult.go index 971c7b7d7692..a66d47b0a532 100644 --- a/workflow/controller/taskresult.go +++ b/workflow/controller/taskresult.go @@ -45,7 +45,10 @@ func (wfc *WorkflowController) newWorkflowTaskResultInformer(ctx context.Context options.LabelSelector = labelSelector // `ResourceVersion=0` does not honor the `limit` in API calls, which results in making significant List calls // without `limit`. For details, see https://github.com/argoproj/argo-workflows/pull/11343 - options.ResourceVersion = "" + // Check if ResourceVersion is "0" and reset it to empty string to avoid missing watch event. + if options.ResourceVersion == "0" { + options.ResourceVersion = "" + } }, ) //nolint:errcheck // the error only happens if the informer was stopped, and it hasn't even started (https://github.com/kubernetes/client-go/blob/46588f2726fa3e25b1704d6418190f424f95a990/tools/cache/shared_informer.go#L580)