Skip to content

Commit a154a93

Browse files
authored
fix: constraint containerType outboundnode boundary. Fixes argoproj#12997 (argoproj#13048)
Signed-off-by: Tianchu Zhao <evantczhao@gmail.com>
1 parent f6c567d commit a154a93

File tree

2 files changed

+156
-1
lines changed

2 files changed

+156
-1
lines changed

workflow/controller/operator.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,16 @@ func (woc *wfOperationCtx) getOutboundNodes(nodeID string) []string {
28612861
}
28622862
outboundNodes := make([]string, 0)
28632863
for _, child := range node.Children {
2864-
outboundNodes = append(outboundNodes, woc.getOutboundNodes(child)...)
2864+
childNode, err := woc.wf.Status.Nodes.Get(child)
2865+
if err != nil {
2866+
woc.log.Panicf("was unable to obtain child node for %s", child)
2867+
}
2868+
// child node has different boundaryID meaning current node is the deepest outbound node
2869+
if node.Type == wfv1.NodeTypeContainer && node.BoundaryID != childNode.BoundaryID {
2870+
outboundNodes = append(outboundNodes, node.ID)
2871+
} else {
2872+
outboundNodes = append(outboundNodes, woc.getOutboundNodes(child)...)
2873+
}
28652874
}
28662875
return outboundNodes
28672876
case wfv1.NodeTypeRetry:

workflow/controller/operator_test.go

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11274,3 +11274,149 @@ func TestContainerSetDeleteContainerWhenPodDeleted(t *testing.T) {
1127411274
}
1127511275
}
1127611276
}
11277+
11278+
var dagContainersetWf = `
11279+
apiVersion: argoproj.io/v1alpha1
11280+
kind: Workflow
11281+
metadata:
11282+
annotations:
11283+
workflows.argoproj.io/pod-name-format: v2
11284+
name: dag-containerset-qlmzl
11285+
namespace: argo
11286+
labels:
11287+
workflows.argoproj.io/completed: "false"
11288+
workflows.argoproj.io/phase: Running
11289+
spec:
11290+
entrypoint: pipeline
11291+
templates:
11292+
- containerSet:
11293+
containers:
11294+
- args:
11295+
- echo
11296+
- hello
11297+
command:
11298+
- /argosay
11299+
image: argoproj/argosay:v2
11300+
name: main
11301+
name: argosay-container-set
11302+
- dag:
11303+
tasks:
11304+
- name: A
11305+
template: argosay-container-set
11306+
- depends: A.Succeeded
11307+
name: B
11308+
template: argosay-container-set
11309+
- depends: A.Succeeded
11310+
name: C
11311+
template: argosay-container-set
11312+
name: pipeline
11313+
status:
11314+
conditions:
11315+
- status: "False"
11316+
type: PodRunning
11317+
finishedAt: null
11318+
nodes:
11319+
dag-containerset-qlmzl:
11320+
children:
11321+
- dag-containerset-qlmzl-1127450597
11322+
displayName: dag-containerset-qlmzl
11323+
finishedAt: null
11324+
id: dag-containerset-qlmzl
11325+
name: dag-containerset-qlmzl
11326+
phase: Running
11327+
progress: 2/6
11328+
startedAt: "2024-05-14T02:24:54Z"
11329+
templateName: pipeline
11330+
templateScope: local/dag-containerset-qlmzl
11331+
type: DAG
11332+
dag-containerset-qlmzl-70023156:
11333+
boundaryID: dag-containerset-qlmzl-1127450597
11334+
children:
11335+
- dag-containerset-qlmzl-1077117740
11336+
displayName: main
11337+
finishedAt: "2024-05-14T02:25:28Z"
11338+
id: dag-containerset-qlmzl-70023156
11339+
name: dag-containerset-qlmzl.A.main
11340+
phase: Succeeded
11341+
progress: 1/1
11342+
startedAt: "2024-05-14T02:24:54Z"
11343+
templateName: argosay-container-set
11344+
templateScope: local/dag-containerset-qlmzl
11345+
type: Container
11346+
dag-containerset-qlmzl-1077117740:
11347+
boundaryID: dag-containerset-qlmzl
11348+
children:
11349+
- dag-containerset-qlmzl-3500746831
11350+
displayName: B
11351+
finishedAt: null
11352+
hostNodeName: k3d-k3s-default-server-0
11353+
id: dag-containerset-qlmzl-1077117740
11354+
message: PodInitializing
11355+
name: dag-containerset-qlmzl.B
11356+
phase: Pending
11357+
progress: 0/1
11358+
startedAt: "2024-05-14T02:25:30Z"
11359+
templateName: argosay-container-set
11360+
templateScope: local/dag-containerset-qlmzl
11361+
type: Pod
11362+
dag-containerset-qlmzl-1127450597:
11363+
boundaryID: dag-containerset-qlmzl
11364+
children:
11365+
- dag-containerset-qlmzl-70023156
11366+
displayName: A
11367+
finishedAt: "2024-05-14T02:25:27Z"
11368+
hostNodeName: k3d-k3s-default-server-0
11369+
id: dag-containerset-qlmzl-1127450597
11370+
name: dag-containerset-qlmzl.A
11371+
outputs:
11372+
exitCode: "0"
11373+
phase: Succeeded
11374+
progress: 1/1
11375+
resourcesDuration:
11376+
cpu: 6
11377+
memory: 49
11378+
startedAt: "2024-05-14T02:24:54Z"
11379+
templateName: argosay-container-set
11380+
templateScope: local/dag-containerset-qlmzl
11381+
type: Pod
11382+
dag-containerset-qlmzl-3500746831:
11383+
boundaryID: dag-containerset-qlmzl-1077117740
11384+
displayName: main
11385+
finishedAt: null
11386+
id: dag-containerset-qlmzl-3500746831
11387+
name: dag-containerset-qlmzl.B.main
11388+
phase: Pending
11389+
progress: 0/1
11390+
startedAt: "2024-05-14T02:25:30Z"
11391+
templateName: argosay-container-set
11392+
templateScope: local/dag-containerset-qlmzl
11393+
type: Container
11394+
phase: Running
11395+
progress: 2/4
11396+
resourcesDuration:
11397+
cpu: 6
11398+
memory: 49
11399+
startedAt: "2024-05-14T02:24:54Z"
11400+
taskResultsCompletionStatus:
11401+
dag-containerset-qlmzl-1077117740: false
11402+
dag-containerset-qlmzl-1127450597: true
11403+
`
11404+
11405+
func TestGetOutboundNodesFromDAGContainerset(t *testing.T) {
11406+
wf := wfv1.MustUnmarshalWorkflow(dagContainersetWf)
11407+
cancel, controller := newController(wf)
11408+
defer cancel()
11409+
11410+
ctx := context.Background()
11411+
woc := newWorkflowOperationCtx(wf, controller)
11412+
woc.operate(ctx)
11413+
11414+
found := false
11415+
for _, node := range woc.wf.Status.Nodes {
11416+
if node.Name == "dag-containerset-qlmzl.A.main" {
11417+
assert.Equal(t, 2, len(node.Children))
11418+
found = true
11419+
}
11420+
}
11421+
assert.Equal(t, true, found)
11422+
}

0 commit comments

Comments
 (0)