diff --git a/cmd/argoexec/commands/wait.go b/cmd/argoexec/commands/wait.go index 2087673621c9..d29b34ce2f57 100644 --- a/cmd/argoexec/commands/wait.go +++ b/cmd/argoexec/commands/wait.go @@ -31,6 +31,15 @@ func waitContainer(ctx context.Context) error { // Don't allow cancellation to impact capture of results, parameters, artifacts, or defers. bgCtx := context.Background() + if wfExecutor.Template.Resource != nil { + err := wfExecutor.Wait(ctx) + if err != nil { + wfExecutor.AddError(err) + } + wfExecutor.SaveLogs(bgCtx) + return wfExecutor.HasError() + } + defer wfExecutor.HandleError(bgCtx) // Must be placed at the bottom of defers stack. defer wfExecutor.FinalizeOutput(bgCtx) // Ensures the LabelKeyReportOutputsCompleted is set to true. defer stats.LogStats() diff --git a/test/e2e/resource_template_test.go b/test/e2e/resource_template_test.go index 95cb785376e3..b1fc913d3029 100644 --- a/test/e2e/resource_template_test.go +++ b/test/e2e/resource_template_test.go @@ -168,7 +168,7 @@ spec: serviceAccountName: argo automountServiceAccountToken: false executor: - serviceAccountName: argo + serviceAccountName: default entrypoint: main templates: - name: main diff --git a/workflow/controller/workflowpod.go b/workflow/controller/workflowpod.go index 735b6ac04e07..0e26ca3320bf 100644 --- a/workflow/controller/workflowpod.go +++ b/workflow/controller/workflowpod.go @@ -212,10 +212,11 @@ func (woc *wfOperationCtx) createWorkflowPod(ctx context.Context, nodeName strin return nil, err } - if tmpl.GetType() != wfv1.TemplateTypeResource && tmpl.GetType() != wfv1.TemplateTypeData { - // we do not need the wait container for resource templates because + if tmpl.GetType() != wfv1.TemplateTypeData { + // we do not need the wait container for data templates because // argoexec runs as the main container and will perform the job of // annotating the outputs or errors, making the wait container redundant. + // for resource template, add a wait container to collect logs. waitCtr := woc.newWaitContainer(tmpl) pod.Spec.Containers = append(pod.Spec.Containers, *waitCtr) }