Skip to content

Commit

Permalink
fix(controller): Fix pod spec jumbling. Fixes #5897 (#5899)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec committed May 13, 2021
1 parent 9a10bd4 commit e71d33c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/e2e/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand All @@ -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")
}
}
})
Expand Down
1 change: 1 addition & 0 deletions workflow/controller/workflowpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e71d33c

Please sign in to comment.