Skip to content

Commit

Permalink
fix(controller): Correct limit in controller List API when Relist c…
Browse files Browse the repository at this point in the history
…alled

Signed-off-by: Yuping Fan <[email protected]>
  • Loading branch information
fyp711 committed Aug 14, 2024
1 parent b6d6403 commit 429ce4b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions workflow/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ const (
ArgoProgressPath = VarRunArgoPath + "/progress"

ConfigMapName = "workflow-controller-configmap"

// DefaultPageSize is the limit value of the request k8s apiserver
DefaultPageSize = 500
)

// AnnotationKeyKillCmd specifies the command to use to kill to container, useful for injected sidecars
Expand Down
3 changes: 3 additions & 0 deletions workflow/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,9 @@ func (wfc *WorkflowController) tweakListRequestListOptions(options *metav1.ListO
// `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 = ""
if options.Limit == 0 {
options.Limit = common.DefaultPageSize
}
}

func (wfc *WorkflowController) tweakWatchRequestListOptions(options *metav1.ListOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package informer
import (
"time"

"github.com/argoproj/argo-workflows/v3/workflow/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
Expand All @@ -25,6 +27,9 @@ func NewTolerantClusterWorkflowTemplateInformer(dynamicInterface dynamic.Interfa
// `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 = ""
if options.Limit == 0 {
options.Limit = common.DefaultPageSize
}
}).ForResource(schema.GroupVersionResource{Group: workflow.Group, Version: workflow.Version, Resource: workflow.ClusterWorkflowTemplatePlural})}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package informer
import (
"time"

"github.com/argoproj/argo-workflows/v3/workflow/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
Expand All @@ -25,6 +27,9 @@ func NewTolerantWorkflowTemplateInformer(dynamicInterface dynamic.Interface, def
// `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 = ""
if options.Limit == 0 {
options.Limit = common.DefaultPageSize
}
}).ForResource(schema.GroupVersionResource{Group: workflow.Group, Version: workflow.Version, Resource: workflow.WorkflowTemplatePlural})}
}

Expand Down
3 changes: 3 additions & 0 deletions workflow/controller/taskresult.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func (wfc *WorkflowController) newWorkflowTaskResultInformer() cache.SharedIndex
// `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 = ""
if options.Limit == 0 {
options.Limit = common.DefaultPageSize
}
},
)
//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)
Expand Down

0 comments on commit 429ce4b

Please sign in to comment.