Skip to content

Commit

Permalink
fix(controller): Error template ref exit handlers. Fixes #5835 (#5837)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored May 10, 2021
1 parent d3eb5bc commit 3428b83
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
35 changes: 35 additions & 0 deletions test/e2e/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,41 @@ func (s *FunctionalSuite) TestWorkflowTemplateRefWithExitHandler() {
})
}

func (s *FunctionalSuite) TestWorkflowTemplateRefWithExitHandlerError() {
s.Given().
WorkflowTemplate(`
metadata:
name: test-exit-handler
spec:
entrypoint: main
onExit: exit-handler
templates:
- name: main
container:
name: main
image: argoproj/argosay:v2
- name: exit-handler
templateRef:
name: nonexistent
template: exit-handler
`).
Workflow(`
metadata:
generateName: test-exit-handler-
spec:
workflowTemplateRef:
name: test-exit-handler
`).
When().
CreateWorkflowTemplates().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeErrored).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Contains(t, status.Message, "error in exit template execution")
})
}

func (s *FunctionalSuite) TestParametrizableAds() {
s.Given().
Workflow(`
Expand Down
4 changes: 3 additions & 1 deletion workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,10 @@ func (woc *wfOperationCtx) operate(ctx context.Context) {
onExitNodeName := common.GenerateOnExitNodeName(woc.wf.ObjectMeta.Name)
onExitNode, err = woc.executeTemplate(ctx, onExitNodeName, &wfv1.WorkflowStep{Template: woc.execWf.Spec.OnExit}, tmplCtx, woc.execWf.Spec.Arguments, &executeTemplateOpts{onExitTemplate: true})
if err != nil {
// the error are handled in the callee so just log it.
woc.log.WithError(err).Error("error in exit template execution")
if !woc.wf.Status.Phase.Completed() {
woc.markWorkflowError(ctx, fmt.Errorf("error in exit template execution: %w", err))
}
return
}
if onExitNode == nil || !onExitNode.Fulfilled() {
Expand Down

0 comments on commit 3428b83

Please sign in to comment.