Skip to content

Commit

Permalink
fix: Correct limit in controller List API calls. Fixes #11134 (#11343)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Tang <[email protected]>
  • Loading branch information
terrytangyuan committed Jul 19, 2023
1 parent 3e17d56 commit f7bf6ee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions workflow/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,9 @@ func (wfc *WorkflowController) tweakListOptions(options *metav1.ListOptions) {
labelSelector := labels.NewSelector().
Add(util.InstanceIDRequirement(wfc.Config.InstanceID))
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 = ""

This comment has been minimized.

Copy link
@fyp711

fyp711 Aug 13, 2024

Contributor

@terrytangyuan Hi, This code overwrites the last resourceversion recorded by informer. All List requests request etcd directly, resulting in an etcd overload. Could i ask why always set ResourceVersion="" ? .

This comment has been minimized.

Copy link
@agilgur5

agilgur5 Aug 16, 2024

Resolved in #13466

}

func getWfPriority(obj interface{}) (int32, time.Time) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ type tolerantClusterWorkflowTemplateInformer struct {

// a drop-in replacement for `extwfv1.ClusterWorkflowTemplateInformer` that ignores malformed resources
func NewTolerantClusterWorkflowTemplateInformer(dynamicInterface dynamic.Interface, defaultResync time.Duration) extwfv1.ClusterWorkflowTemplateInformer {
return &tolerantClusterWorkflowTemplateInformer{delegate: dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynamicInterface, defaultResync, "", func(options *metav1.ListOptions) {}).
ForResource(schema.GroupVersionResource{Group: workflow.Group, Version: workflow.Version, Resource: workflow.ClusterWorkflowTemplatePlural})}
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 = ""
}).ForResource(schema.GroupVersionResource{Group: workflow.Group, Version: workflow.Version, Resource: workflow.ClusterWorkflowTemplatePlural})}
}

func (t *tolerantClusterWorkflowTemplateInformer) Informer() cache.SharedIndexInformer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ type tolerantWorkflowTemplateInformer struct {

// a drop-in replacement for `extwfv1.WorkflowTemplateInformer` that ignores malformed resources
func NewTolerantWorkflowTemplateInformer(dynamicInterface dynamic.Interface, defaultResync time.Duration, namespace string) extwfv1.WorkflowTemplateInformer {
return &tolerantWorkflowTemplateInformer{delegate: dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynamicInterface, defaultResync, namespace, func(options *metav1.ListOptions) {}).
ForResource(schema.GroupVersionResource{Group: workflow.Group, Version: workflow.Version, Resource: workflow.WorkflowTemplatePlural})}
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 = ""
}).ForResource(schema.GroupVersionResource{Group: workflow.Group, Version: workflow.Version, Resource: workflow.WorkflowTemplatePlural})}
}

func (t *tolerantWorkflowTemplateInformer) Informer() cache.SharedIndexInformer {
Expand Down

0 comments on commit f7bf6ee

Please sign in to comment.