Skip to content

Commit

Permalink
feat: log format option for wait and init containers. Fixes #8986 (#9169
Browse files Browse the repository at this point in the history
)

* feat: log format option for wait and init containers. Fixes #8986 (#1)

related to: #7361
fixes #8986

Signed-off-by: Hunter-Thompson <aatman@auroville.org.in>

* fix: use log-format arg instead of creating executor-log-format

Signed-off-by: Hunter-Thompson <aatman@auroville.org.in>
  • Loading branch information
Hunter-Thompson authored Jul 20, 2022
1 parent 573fe98 commit e4489f5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
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()}
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

0 comments on commit e4489f5

Please sign in to comment.