Skip to content

Commit

Permalink
Fixed onexit on workflowtempalteRef (#3263)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarabala1979 committed Jun 20, 2020
1 parent 54dd72c commit 56694ab
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/apis/workflow/v1alpha1/workflow_types.go
Expand Up @@ -1835,6 +1835,13 @@ func (wf *Workflow) GetTemplateByName(name string) *Template {
return &t
}
}
if wf.Status.StoredWorkflowSpec != nil {
for _, t := range wf.Status.StoredWorkflowSpec.Templates {
if t.Name == name {
return &t
}
}
}
return nil
}

Expand Down
17 changes: 17 additions & 0 deletions test/e2e/functional_test.go
Expand Up @@ -582,6 +582,23 @@ func (s *FunctionalSuite) TestOptionalInputArtifacts() {
})
}

func (s *FunctionalSuite) TestWorkflowTemplateRefWithExitHandler() {
s.Given().
WorkflowTemplate("@smoke/workflow-template-whalesay-template.yaml").
When().
CreateWorkflowTemplates()
s.Given().
Workflow("@testdata/workflow-template-ref-exithandler.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(30 * time.Second).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.NodeSucceeded, status.Phase)
})

}

func TestFunctionalSuite(t *testing.T) {
suite.Run(t, new(FunctionalSuite))
}
6 changes: 6 additions & 0 deletions test/e2e/smoke/workflow-template-whalesay-template.yaml
Expand Up @@ -6,6 +6,7 @@ metadata:
argo-e2e: true
spec:
entrypoint: whalesay-template
onExit: on-exit
arguments:
parameters:
- name: message
Expand All @@ -19,3 +20,8 @@ spec:
image: argoproj/argosay:v2
args: ["echo", "{{inputs.parameters.message}}"]
imagePullPolicy: IfNotPresent
- name: on-exit
container:
image: argoproj/argosay:v2
args: ["echo", "Exit Handler"]
imagePullPolicy: IfNotPresent
14 changes: 14 additions & 0 deletions test/e2e/testdata/workflow-template-ref-exithandler.yaml
@@ -0,0 +1,14 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: workflow-template-hello-world-
labels:
argo-e2e: "true"
spec:
entrypoint: whalesay-template
arguments:
parameters:
- name: message
value: "hello world"
workflowTemplateRef:
name: workflow-template-whalesay-template

0 comments on commit 56694ab

Please sign in to comment.