Skip to content

Commit

Permalink
perf: Use template store for all viable get requests
Browse files Browse the repository at this point in the history
Remove Lister() method (as informer don't support full k8s list options)

Signed-off-by: Jakub Buczak <[email protected]>
  • Loading branch information
jakkubu committed Oct 9, 2024
1 parent c884d1d commit fbf13ba
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ func (cwts *ClusterWorkflowTemplateServer) GetClusterWorkflowTemplate(ctx contex
}

func (cwts *ClusterWorkflowTemplateServer) getTemplateAndValidate(ctx context.Context, name string) (*v1alpha1.ClusterWorkflowTemplate, error) {
wfClient := auth.GetWfClient(ctx)
wfTmpl, err := wfClient.ArgoprojV1alpha1().ClusterWorkflowTemplates().Get(ctx, name, v1.GetOptions{})
wfTmpl, err := cwts.cwftmplStore.Getter(ctx).Get(name)
if err != nil {
return nil, serverutils.ToStatusError(err, codes.Internal)
}
Expand Down
9 changes: 0 additions & 9 deletions server/clusterworkflowtemplate/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"k8s.io/client-go/tools/cache"

wfextvv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/client/informers/externalversions/workflow/v1alpha1"
clientv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/client/listers/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/server/types"
"github.com/argoproj/argo-workflows/v3/workflow/controller/informer"
"github.com/argoproj/argo-workflows/v3/workflow/templateresolution"
Expand Down Expand Up @@ -56,14 +55,6 @@ func (cwti *Informer) Run(stopCh <-chan struct{}) {
}
}

// if namespace contains empty string Lister will use the namespace provided during initialization
func (cwti *Informer) Lister(_ context.Context, namespace string) clientv1alpha1.ClusterWorkflowTemplateLister {
if cwti.informer == nil {
log.Fatal("Template informer not started")
}
return cwti.informer.Lister()
}

// if namespace contains empty string Lister will use the namespace provided during initialization
func (cwti *Informer) Getter(_ context.Context) templateresolution.ClusterWorkflowTemplateGetter {
if cwti.informer == nil {
Expand Down
12 changes: 0 additions & 12 deletions server/workflowtemplate/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"k8s.io/client-go/tools/cache"

wfextvv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/client/informers/externalversions/workflow/v1alpha1"
clientv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/client/listers/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/server/types"
"github.com/argoproj/argo-workflows/v3/workflow/controller/informer"
"github.com/argoproj/argo-workflows/v3/workflow/templateresolution"
Expand Down Expand Up @@ -58,17 +57,6 @@ func (wti *Informer) Run(stopCh <-chan struct{}) {
}
}

// if namespace contains empty string Lister will use the namespace provided during initialization
func (wti *Informer) Lister(_ context.Context, namespace string) clientv1alpha1.WorkflowTemplateNamespaceLister {
if wti.informer == nil {
log.Fatal("Template informer not started")
}
if namespace == "" {
namespace = wti.managedNamespace
}
return wti.informer.Lister().WorkflowTemplates(namespace)
}

// if namespace contains empty string Lister will use the namespace provided during initialization
func (wti *Informer) Getter(_ context.Context, namespace string) templateresolution.WorkflowTemplateNamespacedGetter {
if wti.informer == nil {
Expand Down
3 changes: 1 addition & 2 deletions server/workflowtemplate/workflow_template_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ func (wts *WorkflowTemplateServer) GetWorkflowTemplate(ctx context.Context, req
}

func (wts *WorkflowTemplateServer) getTemplateAndValidate(ctx context.Context, namespace string, name string) (*v1alpha1.WorkflowTemplate, error) {
wfClient := auth.GetWfClient(ctx)
wfTmpl, err := wfClient.ArgoprojV1alpha1().WorkflowTemplates(namespace).Get(ctx, name, v1.GetOptions{})
wfTmpl, err := wts.wftmplStore.Getter(ctx, namespace).Get(name)
if err != nil {
return nil, sutils.ToStatusError(err, codes.Internal)
}
Expand Down

0 comments on commit fbf13ba

Please sign in to comment.