Skip to content

Commit

Permalink
fix: Panic on nill pointer when running a workflow with restricted pa…
Browse files Browse the repository at this point in the history
…rallelism (#9385)

Signed-off-by: Saravanan Balasubramanian <[email protected]>

Signed-off-by: Saravanan Balasubramanian <[email protected]>
  • Loading branch information
sarabala1979 authored Aug 17, 2022
1 parent c756291 commit f53d483
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions workflow/controller/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ func (woc *wfOperationCtx) executeDAGTask(ctx context.Context, dagCtx *dagContex
return
}
}
// Some scenario, Node will be nil e.g: when parallelism reached.
if node == nil {
return
}
if node.Completed() {
// if the node type is NodeTypeRetry, and its last child is completed, it will be completed after woc.executeTemplate;
hasOnExitNode, onExitNode, err := woc.runOnExitNode(ctx, task.GetExitHook(woc.execWf.Spec.Arguments), node, dagCtx.boundaryID, dagCtx.tmplCtx, "tasks."+taskName)
Expand Down
47 changes: 47 additions & 0 deletions workflow/controller/dag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3590,3 +3590,50 @@ func TestRetryTypeDagTaskRunExitNodeAfterCompleted(t *testing.T) {
assert.NotNil(t, nextDAGTaskNode)
assert.Equal(t, wfv1.NodeRunning, nextDAGTaskNode.Phase)
}

func TestDagParallelism(t *testing.T) {
wf := wfv1.MustUnmarshalWorkflow(`apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: test-parallelism
namespace: argo
spec:
entrypoint: main
parallelism: 1
templates:
- name: main
dag:
tasks:
- name: do-it-once
template: do-it
arguments:
parameters:
- name: thing
value: 1
- name: do-it-twice
template: do-it
arguments:
parameters:
- name: thing
value: 2
- name: do-it-thrice
template: do-it
arguments:
parameters:
- name: thing
value: 3
- name: do-it
inputs:
parameters:
- name: thing
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["I have a {{inputs.parameters.thing}}"]`)
woc := newWoc(*wf)
ctx := context.Background()
woc.operate(ctx)
woc1 := newWoc(*woc.wf)
woc1.operate(ctx)
assert.Equal(t, wfv1.WorkflowRunning, woc.wf.Status.Phase)
}

0 comments on commit f53d483

Please sign in to comment.