From dd8796cc315de001d6ac57146b002473bf36b7a3 Mon Sep 17 00:00:00 2001 From: Michael Weibel Date: Tue, 22 Nov 2022 17:23:37 +0100 Subject: [PATCH] fix: reconcile wf when taskresult is added/updated Re-adds an EventHandler to trigger an update when a WorkflowTaskResult got added/updated. Without this, a workflow progress only gets updated upon completion or every 20mins. Fixes #10096, bug introduced in #8135 Signed-off-by: Michael Weibel --- workflow/controller/taskresult.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/workflow/controller/taskresult.go b/workflow/controller/taskresult.go index 0af6383b3b7c..6a584cea2055 100644 --- a/workflow/controller/taskresult.go +++ b/workflow/controller/taskresult.go @@ -11,6 +11,7 @@ import ( wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" wfextvv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/client/informers/externalversions/workflow/v1alpha1" + "github.com/argoproj/argo-workflows/v3/workflow/common" "github.com/argoproj/argo-workflows/v3/workflow/controller/indexes" ) @@ -21,7 +22,7 @@ func (wfc *WorkflowController) newWorkflowTaskResultInformer() cache.SharedIndex String() log.WithField("labelSelector", labelSelector). Info("Watching task results") - return wfextvv1alpha1.NewFilteredWorkflowTaskResultInformer( + informer := wfextvv1alpha1.NewFilteredWorkflowTaskResultInformer( wfc.wfclientset, wfc.GetManagedNamespace(), 20*time.Minute, @@ -32,6 +33,20 @@ func (wfc *WorkflowController) newWorkflowTaskResultInformer() cache.SharedIndex options.LabelSelector = labelSelector }, ) + informer.AddEventHandler( + cache.ResourceEventHandlerFuncs{ + AddFunc: func(new interface{}) { + result := new.(*wfv1.WorkflowTaskResult) + workflow := result.Labels[common.LabelKeyWorkflow] + wfc.wfQueue.AddRateLimited(result.Namespace + "/" + workflow) + }, + UpdateFunc: func(old, new interface{}) { + result := new.(*wfv1.WorkflowTaskResult) + workflow := result.Labels[common.LabelKeyWorkflow] + wfc.wfQueue.AddRateLimited(result.Namespace + "/" + workflow) + }, + }) + return informer } func (woc *wfOperationCtx) taskResultReconciliation() {