Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log format option for wait and init containers. Fixes #8986 #9169

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/workflow-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions workflow/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
13 changes: 10 additions & 3 deletions workflow/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions workflow/controller/workflowpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Hunter-Thompson marked this conversation as resolved.
Show resolved Hide resolved
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
}

Expand Down