Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Workflow level http template hook status update. Fixes #8529 #8586

Merged
merged 6 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion workflow/controller/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ func (woc *wfOperationCtx) executeWfLifeCycleHook(ctx context.Context, tmplCtx *
if execute {
hookNodeName := generateLifeHookNodeName(woc.wf.ObjectMeta.Name, string(hookName))
woc.log.WithField("lifeCycleHook", hookName).WithField("node", hookNodeName).Infof("Running workflow level hooks")
_, err := woc.executeTemplate(ctx, hookNodeName, &wfv1.WorkflowStep{Template: hook.Template, TemplateRef: hook.TemplateRef}, tmplCtx, hook.Arguments, &executeTemplateOpts{})
hookNode, err := woc.executeTemplate(ctx, hookNodeName, &wfv1.WorkflowStep{Template: hook.Template, TemplateRef: hook.TemplateRef}, tmplCtx, hook.Arguments, &executeTemplateOpts{})
if err != nil {
return err
}
woc.addChildNode(woc.wf.Name, hookNodeName)
// If the hookNode node is HTTP template, it requires HTTP reconciliation, do it here
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
if hookNode != nil && woc.nodeRequiresTaskSetReconciliation(hookNode.Name) {
woc.taskSetReconciliation(ctx)
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions workflow/controller/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,4 +986,12 @@ spec:
woc.globalParams[common.GlobalVarWorkflowFailures],
`[{\"displayName\":\"hook-failures\",\"message\":\"Pod failed\",\"templateName\":\"intentional-fail\",\"phase\":\"Failed\",\"podName\":\"hook-failures\"`,
)
assert.Equal(t, wfv1.NodePending, node.Phase)
makePodsPhase(ctx, woc, apiv1.PodFailed)
woc = newWorkflowOperationCtx(woc.wf, controller)
err := woc.podReconciliation(ctx)
assert.NoError(t, err)
node = woc.wf.Status.Nodes.FindByDisplayName("hook-failures.hooks.failure")
assert.NotNil(t, node)
assert.Equal(t, wfv1.NodeFailed, node.Phase)
}