From e71d33c54bd3657a4d63ae8bfa3d899b3339d0fb Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Thu, 13 May 2021 08:42:31 -0700 Subject: [PATCH] fix(controller): Fix pod spec jumbling. Fixes #5897 (#5899) Signed-off-by: Alex Collins --- test/e2e/functional_test.go | 8 ++++---- workflow/controller/workflowpod.go | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/e2e/functional_test.go b/test/e2e/functional_test.go index d82a304e3a06..9f4d95b1e1c7 100644 --- a/test/e2e/functional_test.go +++ b/test/e2e/functional_test.go @@ -670,10 +670,8 @@ spec: - name: main container: image: argoproj/argosay:v2 - args: - - echo - - ":) Hello Argo!" - podSpecPatch: '{"terminationGracePeriodSeconds":5, "containers":[{"name":"main", "resources":{"limits":{"cpu": "100m"}}}]}' + # ordering of the containers in the next line is intentionally reversed + podSpecPatch: '{"terminationGracePeriodSeconds":5, "containers":[{"name":"main", "resources":{"limits":{"cpu": "100m"}}}, {"name":"wait", "resources":{"limits":{"cpu": "101m"}}}]}' `). When(). SubmitWorkflow(). @@ -684,6 +682,8 @@ spec: for _, c := range p.Spec.Containers { if c.Name == "main" { assert.Equal(t, c.Resources.Limits.Cpu().String(), "100m") + } else if c.Name == "wait" { + assert.Equal(t, c.Resources.Limits.Cpu().String(), "101m") } } }) diff --git a/workflow/controller/workflowpod.go b/workflow/controller/workflowpod.go index 441ea79e6e2e..4cfce3773e86 100644 --- a/workflow/controller/workflowpod.go +++ b/workflow/controller/workflowpod.go @@ -390,6 +390,7 @@ func (woc *wfOperationCtx) createWorkflowPod(ctx context.Context, nodeName strin if err != nil { return nil, errors.Wrap(err, "", "Error occurred during strategic merge patch") } + pod.Spec = apiv1.PodSpec{} // zero out the pod spec so we cannot get conflicts err = json.Unmarshal(modJson, &pod.Spec) if err != nil { return nil, errors.Wrap(err, "", "Error in Unmarshalling after merge the patch")