Skip to content

Commit

Permalink
fix: constraint containerType outboundnode boundary. Fixes #12997 (#1…
Browse files Browse the repository at this point in the history
…3048)

Signed-off-by: Tianchu Zhao <evantczhao@gmail.com>
  • Loading branch information
tczhao authored Jul 19, 2024
1 parent f6c567d commit a154a93
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 1 deletion.
11 changes: 10 additions & 1 deletion workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2861,7 +2861,16 @@ func (woc *wfOperationCtx) getOutboundNodes(nodeID string) []string {
}
outboundNodes := make([]string, 0)
for _, child := range node.Children {
outboundNodes = append(outboundNodes, woc.getOutboundNodes(child)...)
childNode, err := woc.wf.Status.Nodes.Get(child)
if err != nil {
woc.log.Panicf("was unable to obtain child node for %s", child)
}
// child node has different boundaryID meaning current node is the deepest outbound node
if node.Type == wfv1.NodeTypeContainer && node.BoundaryID != childNode.BoundaryID {
outboundNodes = append(outboundNodes, node.ID)
} else {
outboundNodes = append(outboundNodes, woc.getOutboundNodes(child)...)
}
}
return outboundNodes
case wfv1.NodeTypeRetry:
Expand Down
146 changes: 146 additions & 0 deletions workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11274,3 +11274,149 @@ func TestContainerSetDeleteContainerWhenPodDeleted(t *testing.T) {
}
}
}

var dagContainersetWf = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
annotations:
workflows.argoproj.io/pod-name-format: v2
name: dag-containerset-qlmzl
namespace: argo
labels:
workflows.argoproj.io/completed: "false"
workflows.argoproj.io/phase: Running
spec:
entrypoint: pipeline
templates:
- containerSet:
containers:
- args:
- echo
- hello
command:
- /argosay
image: argoproj/argosay:v2
name: main
name: argosay-container-set
- dag:
tasks:
- name: A
template: argosay-container-set
- depends: A.Succeeded
name: B
template: argosay-container-set
- depends: A.Succeeded
name: C
template: argosay-container-set
name: pipeline
status:
conditions:
- status: "False"
type: PodRunning
finishedAt: null
nodes:
dag-containerset-qlmzl:
children:
- dag-containerset-qlmzl-1127450597
displayName: dag-containerset-qlmzl
finishedAt: null
id: dag-containerset-qlmzl
name: dag-containerset-qlmzl
phase: Running
progress: 2/6
startedAt: "2024-05-14T02:24:54Z"
templateName: pipeline
templateScope: local/dag-containerset-qlmzl
type: DAG
dag-containerset-qlmzl-70023156:
boundaryID: dag-containerset-qlmzl-1127450597
children:
- dag-containerset-qlmzl-1077117740
displayName: main
finishedAt: "2024-05-14T02:25:28Z"
id: dag-containerset-qlmzl-70023156
name: dag-containerset-qlmzl.A.main
phase: Succeeded
progress: 1/1
startedAt: "2024-05-14T02:24:54Z"
templateName: argosay-container-set
templateScope: local/dag-containerset-qlmzl
type: Container
dag-containerset-qlmzl-1077117740:
boundaryID: dag-containerset-qlmzl
children:
- dag-containerset-qlmzl-3500746831
displayName: B
finishedAt: null
hostNodeName: k3d-k3s-default-server-0
id: dag-containerset-qlmzl-1077117740
message: PodInitializing
name: dag-containerset-qlmzl.B
phase: Pending
progress: 0/1
startedAt: "2024-05-14T02:25:30Z"
templateName: argosay-container-set
templateScope: local/dag-containerset-qlmzl
type: Pod
dag-containerset-qlmzl-1127450597:
boundaryID: dag-containerset-qlmzl
children:
- dag-containerset-qlmzl-70023156
displayName: A
finishedAt: "2024-05-14T02:25:27Z"
hostNodeName: k3d-k3s-default-server-0
id: dag-containerset-qlmzl-1127450597
name: dag-containerset-qlmzl.A
outputs:
exitCode: "0"
phase: Succeeded
progress: 1/1
resourcesDuration:
cpu: 6
memory: 49
startedAt: "2024-05-14T02:24:54Z"
templateName: argosay-container-set
templateScope: local/dag-containerset-qlmzl
type: Pod
dag-containerset-qlmzl-3500746831:
boundaryID: dag-containerset-qlmzl-1077117740
displayName: main
finishedAt: null
id: dag-containerset-qlmzl-3500746831
name: dag-containerset-qlmzl.B.main
phase: Pending
progress: 0/1
startedAt: "2024-05-14T02:25:30Z"
templateName: argosay-container-set
templateScope: local/dag-containerset-qlmzl
type: Container
phase: Running
progress: 2/4
resourcesDuration:
cpu: 6
memory: 49
startedAt: "2024-05-14T02:24:54Z"
taskResultsCompletionStatus:
dag-containerset-qlmzl-1077117740: false
dag-containerset-qlmzl-1127450597: true
`

func TestGetOutboundNodesFromDAGContainerset(t *testing.T) {
wf := wfv1.MustUnmarshalWorkflow(dagContainersetWf)
cancel, controller := newController(wf)
defer cancel()

ctx := context.Background()
woc := newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)

found := false
for _, node := range woc.wf.Status.Nodes {
if node.Name == "dag-containerset-qlmzl.A.main" {
assert.Equal(t, 2, len(node.Children))
found = true
}
}
assert.Equal(t, true, found)
}

0 comments on commit a154a93

Please sign in to comment.