Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 448c492

Browse files
authored
fix: ensure pod used container templates are copies (#14773)
Signed-off-by: Alan Clucas <[email protected]>
1 parent ba9257b commit 448c492

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

workflow/controller/operator.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3043,7 +3043,8 @@ func (woc *wfOperationCtx) executeContainer(ctx context.Context, nodeName string
30433043
}
30443044

30453045
woc.log.WithFields(logging.Fields{"nodeName": nodeName, "template": tmpl.Name}).Debug(ctx, "Executing node with container template")
3046-
_, err = woc.createWorkflowPod(ctx, nodeName, []apiv1.Container{*tmpl.Container}, tmpl, &createWorkflowPodOpts{
3046+
ctr := tmpl.Container.DeepCopy()
3047+
_, err = woc.createWorkflowPod(ctx, nodeName, []apiv1.Container{*ctr}, tmpl, &createWorkflowPodOpts{
30473048
includeScriptOutput: includeScriptOutput,
30483049
onExitPod: opts.onExitTemplate,
30493050
executionDeadline: opts.executionDeadline,
@@ -3260,13 +3261,13 @@ func (woc *wfOperationCtx) executeScript(ctx context.Context, nodeName string, t
32603261
return node, err
32613262
}
32623263

3263-
mainCtr := tmpl.Script.Container
3264+
mainCtr := tmpl.Script.Container.DeepCopy()
32643265
if len(tmpl.Script.Source) == 0 {
32653266
woc.log.Warn(ctx, "'script.source' is empty, suggest change template into 'container'")
32663267
} else {
32673268
mainCtr.Args = append(mainCtr.Args, common.ExecutorScriptSourcePath)
32683269
}
3269-
_, err = woc.createWorkflowPod(ctx, nodeName, []apiv1.Container{mainCtr}, tmpl, &createWorkflowPodOpts{
3270+
_, err = woc.createWorkflowPod(ctx, nodeName, []apiv1.Container{*mainCtr}, tmpl, &createWorkflowPodOpts{
32703271
includeScriptOutput: includeScriptOutput,
32713272
onExitPod: opts.onExitTemplate,
32723273
executionDeadline: opts.executionDeadline,

0 commit comments

Comments
 (0)