Skip to content

Commit

Permalink
fix(controller): re-allow changing executor args (#12609)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Gilgur <[email protected]>
  • Loading branch information
agilgur5 authored and isubasinghe committed May 7, 2024
1 parent c590b2e commit 6cda00d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions workflow/controller/workflowpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ func (woc *wfOperationCtx) newExecContainer(name string, tmpl *wfv1.Template) *a
Env: woc.createEnvVars(),
Resources: woc.controller.Config.GetExecutor().Resources,
SecurityContext: woc.controller.Config.GetExecutor().SecurityContext,
Args: woc.controller.Config.GetExecutor().Args,
}
// lock down resource pods by default
if tmpl.GetType() == wfv1.TemplateTypeResource && exec.SecurityContext == nil {
Expand Down
24 changes: 22 additions & 2 deletions workflow/controller/workflowpod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ func TestTmplLevelExecutorServiceAccountName(t *testing.T) {
verifyServiceAccountTokenVolumeMount(t, waitCtr, "exec-sa-token", "/var/run/secrets/kubernetes.io/serviceaccount")
}

// TestTmplLevelExecutorServiceAccountName verifies the ability to carry forward template level AutomountServiceAccountToken to Podspec.
func TestTmplLevelExecutorSecurityContext(t *testing.T) {
// TestCtrlLevelExecutorSecurityContext verifies the ability to carry forward Controller level SecurityContext to Podspec.
func TestCtrlLevelExecutorSecurityContext(t *testing.T) {
var user int64 = 1000
ctx := context.Background()
woc := newWoc()
Expand Down Expand Up @@ -1484,6 +1484,26 @@ func TestMainContainerCustomization(t *testing.T) {
})
}

func TestExecutorContainerCustomization(t *testing.T) {
woc := newWoc()
woc.controller.Config.Executor = &apiv1.Container{
Args: []string{"foo"},
Resources: apiv1.ResourceRequirements{
Limits: apiv1.ResourceList{
apiv1.ResourceCPU: resource.MustParse("0.900"),
apiv1.ResourceMemory: resource.MustParse("512Mi"),
},
},
}

pod, err := woc.createWorkflowPod(context.Background(), "", nil, &wfv1.Template{}, &createWorkflowPodOpts{})
assert.NoError(t, err)
waitCtr := pod.Spec.Containers[0]
assert.Equal(t, []string{"foo"}, waitCtr.Args)
assert.Equal(t, "0.900", waitCtr.Resources.Limits.Cpu().AsDec().String())
assert.Equal(t, "536870912", waitCtr.Resources.Limits.Memory().AsDec().String())
}

var helloWindowsWf = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
Expand Down

0 comments on commit 6cda00d

Please sign in to comment.