diff --git a/cmd/workflow-controller/main.go b/cmd/workflow-controller/main.go index 88c6c1cec1dc..9b8a3964c53a 100644 --- a/cmd/workflow-controller/main.go +++ b/cmd/workflow-controller/main.go @@ -110,7 +110,7 @@ func NewRootCommand() *cobra.Command { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - wfController, err := controller.NewWorkflowController(ctx, config, kubeclientset, wfclientset, namespace, managedNamespace, executorImage, executorImagePullPolicy, containerRuntimeExecutor, configMap, executorPlugins) + wfController, err := controller.NewWorkflowController(ctx, config, kubeclientset, wfclientset, namespace, managedNamespace, executorImage, executorImagePullPolicy, logFormat, containerRuntimeExecutor, configMap, executorPlugins) errors.CheckError(err) leaderElectionOff := os.Getenv("LEADER_ELECTION_DISABLE") diff --git a/workflow/controller/config.go b/workflow/controller/config.go index 698995197fe5..51494e302488 100644 --- a/workflow/controller/config.go +++ b/workflow/controller/config.go @@ -96,6 +96,10 @@ func (wfc *WorkflowController) executorImage() string { return fmt.Sprintf("quay.io/argoproj/argoexec:" + argo.ImageTag()) } +func (wfc *WorkflowController) executorLogFormat() string { + return wfc.cliExecutorLogFormat +} + // executorImagePullPolicy returns the imagePullPolicy to use for the workflow executor func (wfc *WorkflowController) executorImagePullPolicy() apiv1.PullPolicy { if wfc.cliExecutorImagePullPolicy != "" { diff --git a/workflow/controller/controller.go b/workflow/controller/controller.go index df063d6c400b..317c4129375a 100644 --- a/workflow/controller/controller.go +++ b/workflow/controller/controller.go @@ -86,6 +86,10 @@ type WorkflowController struct { cliExecutorImagePullPolicy string containerRuntimeExecutor string + // cliExecutorLogFormat is the format in which argoexec will log + // possible options are json/text + cliExecutorLogFormat string + // restConfig is used by controller to send a SIGUSR1 to the wait sidecar using remotecommand.NewSPDYExecutor(). restConfig *rest.Config kubeclientset kubernetes.Interface @@ -143,7 +147,7 @@ func init() { } // NewWorkflowController instantiates a new WorkflowController -func NewWorkflowController(ctx context.Context, restConfig *rest.Config, kubeclientset kubernetes.Interface, wfclientset wfclientset.Interface, namespace, managedNamespace, executorImage, executorImagePullPolicy, containerRuntimeExecutor, configMap string, executorPlugins bool) (*WorkflowController, error) { +func NewWorkflowController(ctx context.Context, restConfig *rest.Config, kubeclientset kubernetes.Interface, wfclientset wfclientset.Interface, namespace, managedNamespace, executorImage, executorImagePullPolicy, executorLogFormat, containerRuntimeExecutor, configMap string, executorPlugins bool) (*WorkflowController, error) { dynamicInterface, err := dynamic.NewForConfig(restConfig) if err != nil { return nil, err @@ -158,6 +162,7 @@ func NewWorkflowController(ctx context.Context, restConfig *rest.Config, kubecli managedNamespace: managedNamespace, cliExecutorImage: executorImage, cliExecutorImagePullPolicy: executorImagePullPolicy, + cliExecutorLogFormat: executorLogFormat, containerRuntimeExecutor: containerRuntimeExecutor, configController: config.NewController(namespace, configMap, kubeclientset), workflowKeyLock: syncpkg.NewKeyLock(), @@ -924,8 +929,10 @@ func (wfc *WorkflowController) archiveWorkflowAux(ctx context.Context, obj inter return nil } -var incompleteReq, _ = labels.NewRequirement(common.LabelKeyCompleted, selection.Equals, []string{"false"}) -var workflowReq, _ = labels.NewRequirement(common.LabelKeyWorkflow, selection.Exists, nil) +var ( + incompleteReq, _ = labels.NewRequirement(common.LabelKeyCompleted, selection.Equals, []string{"false"}) + workflowReq, _ = labels.NewRequirement(common.LabelKeyWorkflow, selection.Exists, nil) +) func (wfc *WorkflowController) instanceIDReq() labels.Requirement { return util.InstanceIDRequirement(wfc.Config.InstanceID) diff --git a/workflow/controller/workflowpod.go b/workflow/controller/workflowpod.go index f8e0bc0e4428..6899cc3113b2 100644 --- a/workflow/controller/workflowpod.go +++ b/workflow/controller/workflowpod.go @@ -506,13 +506,13 @@ func substitutePodParams(pod *apiv1.Pod, globalParams common.Parameters, tmpl *w func (woc *wfOperationCtx) newInitContainer(tmpl *wfv1.Template) apiv1.Container { ctr := woc.newExecContainer(common.InitContainerName, tmpl) - ctr.Command = []string{"argoexec", "init", "--loglevel", getExecutorLogLevel()} + ctr.Command = []string{"argoexec", "init", "--loglevel", getExecutorLogLevel(), "--log-format", woc.controller.executorLogFormat()} return *ctr } func (woc *wfOperationCtx) newWaitContainer(tmpl *wfv1.Template) *apiv1.Container { ctr := woc.newExecContainer(common.WaitContainerName, tmpl) - ctr.Command = []string{"argoexec", "wait", "--loglevel", getExecutorLogLevel()} + ctr.Command = []string{"argoexec", "wait", "--loglevel", getExecutorLogLevel(), "--log-format", woc.controller.executorLogFormat()} return ctr }