Skip to content

Commit

Permalink
fix: reconcile wf when taskresult is added/updated
Browse files Browse the repository at this point in the history
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 argoproj#10096, bug introduced in argoproj#8135

Signed-off-by: Michael Weibel <michael@helio.exchange>
  • Loading branch information
mweibel committed Nov 22, 2022
1 parent 766f9bd commit dd8796c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion workflow/controller/taskresult.go
Expand Up @@ -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"
)

Expand All @@ -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,
Expand All @@ -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() {
Expand Down

0 comments on commit dd8796c

Please sign in to comment.