From ba7d92092bef7ee01852e4e6ed5b6763e65e10ef Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Sun, 20 Oct 2024 08:17:56 +1100 Subject: [PATCH 1/4] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- workflow/controller/workflowpod.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/workflow/controller/workflowpod.go b/workflow/controller/workflowpod.go index c612b12f0cca..47130313a12d 100644 --- a/workflow/controller/workflowpod.go +++ b/workflow/controller/workflowpod.go @@ -301,6 +301,26 @@ func (woc *wfOperationCtx) createWorkflowPod(ctx context.Context, nodeName strin simplifiedTmpl.Inputs = wfv1.Inputs{ Artifacts: simplifiedTmpl.Inputs.Artifacts, } + + // simplify template by clearing useless volumemounts related to user configmaps ie somecode.py + if simplifiedTmpl.Container != nil && simplifiedTmpl.Container.VolumeMounts != nil { + var filteredVolumeMounts []v1.VolumeMount + for _, mnt := range simplifiedTmpl.Container.VolumeMounts { + isConfigMapVolume := false + for _, vol := range pod.Spec.Volumes { + if vol.Name == mnt.Name && vol.ConfigMap != nil && vol.Name != "argo-env-config" { + isConfigMapVolume = true + break + } + } + if isConfigMapVolume { + continue + } + filteredVolumeMounts = append(filteredVolumeMounts, mnt) + } + simplifiedTmpl.Container.VolumeMounts = filteredVolumeMounts + } + envVarTemplateValue := wfv1.MustMarshallJSON(simplifiedTmpl) // Add standard environment variables, making pod spec larger From f46dbaae558e9707ba91eeb95bbc0dba299cc798 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Sun, 20 Oct 2024 08:31:43 +1100 Subject: [PATCH 2/4] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- workflow/controller/workflowpod.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/controller/workflowpod.go b/workflow/controller/workflowpod.go index 47130313a12d..ce0881c3161f 100644 --- a/workflow/controller/workflowpod.go +++ b/workflow/controller/workflowpod.go @@ -304,7 +304,7 @@ func (woc *wfOperationCtx) createWorkflowPod(ctx context.Context, nodeName strin // simplify template by clearing useless volumemounts related to user configmaps ie somecode.py if simplifiedTmpl.Container != nil && simplifiedTmpl.Container.VolumeMounts != nil { - var filteredVolumeMounts []v1.VolumeMount + var filteredVolumeMounts []apiv1.VolumeMount for _, mnt := range simplifiedTmpl.Container.VolumeMounts { isConfigMapVolume := false for _, vol := range pod.Spec.Volumes { From 81786e3f7ea5e79899382bcca037630a4f105d16 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Sun, 20 Oct 2024 08:45:19 +1100 Subject: [PATCH 3/4] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- workflow/controller/workflowpod.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/workflow/controller/workflowpod.go b/workflow/controller/workflowpod.go index ce0881c3161f..f8be5a721e0a 100644 --- a/workflow/controller/workflowpod.go +++ b/workflow/controller/workflowpod.go @@ -304,21 +304,21 @@ func (woc *wfOperationCtx) createWorkflowPod(ctx context.Context, nodeName strin // simplify template by clearing useless volumemounts related to user configmaps ie somecode.py if simplifiedTmpl.Container != nil && simplifiedTmpl.Container.VolumeMounts != nil { - var filteredVolumeMounts []apiv1.VolumeMount - for _, mnt := range simplifiedTmpl.Container.VolumeMounts { - isConfigMapVolume := false - for _, vol := range pod.Spec.Volumes { - if vol.Name == mnt.Name && vol.ConfigMap != nil && vol.Name != "argo-env-config" { - isConfigMapVolume = true - break - } - } - if isConfigMapVolume { - continue - } - filteredVolumeMounts = append(filteredVolumeMounts, mnt) - } - simplifiedTmpl.Container.VolumeMounts = filteredVolumeMounts + var filteredVolumeMounts []apiv1.VolumeMount + for _, mnt := range simplifiedTmpl.Container.VolumeMounts { + isConfigMapVolume := false + for _, vol := range pod.Spec.Volumes { + if vol.Name == mnt.Name && vol.ConfigMap != nil && vol.Name != "argo-env-config" { + isConfigMapVolume = true + break + } + } + if isConfigMapVolume { + continue + } + filteredVolumeMounts = append(filteredVolumeMounts, mnt) + } + simplifiedTmpl.Container.VolumeMounts = filteredVolumeMounts } envVarTemplateValue := wfv1.MustMarshallJSON(simplifiedTmpl) From 83d37f035267989fe85ffadfc2d271013305c882 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Sun, 20 Oct 2024 09:21:57 +1100 Subject: [PATCH 4/4] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- workflow/controller/workflowpod.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/workflow/controller/workflowpod.go b/workflow/controller/workflowpod.go index f8be5a721e0a..ebe1397728cc 100644 --- a/workflow/controller/workflowpod.go +++ b/workflow/controller/workflowpod.go @@ -320,6 +320,23 @@ func (woc *wfOperationCtx) createWorkflowPod(ctx context.Context, nodeName strin } simplifiedTmpl.Container.VolumeMounts = filteredVolumeMounts } + if simplifiedTmpl.Script != nil && simplifiedTmpl.Script.VolumeMounts != nil { + var filteredVolumeMountsScript []apiv1.VolumeMount + for _, mnt := range simplifiedTmpl.Script.VolumeMounts { + isConfigMapVolumeScript := false + for _, vol := range pod.Spec.Volumes { + if vol.Name == mnt.Name && vol.ConfigMap != nil && vol.Name != "argo-env-config" { + isConfigMapVolumeScript = true + break + } + } + if isConfigMapVolumeScript { + continue + } + filteredVolumeMountsScript = append(filteredVolumeMountsScript, mnt) + } + simplifiedTmpl.Script.VolumeMounts = filteredVolumeMountsScript + } envVarTemplateValue := wfv1.MustMarshallJSON(simplifiedTmpl)