Skip to content

Commit

Permalink
feat(executor): Add user agent to workflow executor (#5014)
Browse files Browse the repository at this point in the history
Signed-off-by: terrytangyuan <[email protected]>
  • Loading branch information
terrytangyuan authored Feb 10, 2021
1 parent f31e0c6 commit 19a34b1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/argoexec/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package commands

import (
"encoding/json"
"fmt"
"os"

"github.com/argoproj/pkg/cli"
kubecli "github.com/argoproj/pkg/kube/cli"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

"github.com/argoproj/argo-workflows/v3"
Expand Down Expand Up @@ -71,8 +73,11 @@ func NewRootCommand() *cobra.Command {
}

func initExecutor() *executor.WorkflowExecutor {
log.WithField("version", argo.GetVersion().Version).Info("Starting Workflow Executor")
version := argo.GetVersion()
log.WithField("version", version).Info("Starting Workflow Executor")
config, err := clientConfig.ClientConfig()
executorType := os.Getenv(common.EnvVarContainerRuntimeExecutor)
config = restclient.AddUserAgent(config, fmt.Sprintf("argo-workflows/%s executor/%s", version.Version, executorType))
checkErr(err)

logs.AddK8SLogTransportWrapper(config) // lets log all request as we should typically do < 5 per pod, so this is will show up problems
Expand All @@ -92,7 +97,7 @@ func initExecutor() *executor.WorkflowExecutor {
checkErr(err)

var cre executor.ContainerRuntimeExecutor
switch os.Getenv(common.EnvVarContainerRuntimeExecutor) {
switch executorType {
case common.ContainerRuntimeExecutorK8sAPI:
cre, err = k8sapi.NewK8sAPIExecutor(clientset, config, podName, namespace)
case common.ContainerRuntimeExecutorKubelet:
Expand All @@ -106,8 +111,7 @@ func initExecutor() *executor.WorkflowExecutor {

wfExecutor := executor.NewExecutor(clientset, podName, namespace, podAnnotationsPath, cre, *tmpl)
yamlBytes, _ := json.Marshal(&wfExecutor.Template)
vers := argo.GetVersion()
log.Infof("Executor (version: %s, build_date: %s) initialized (pod: %s/%s) with template:\n%s", vers.Version, vers.BuildDate, namespace, podName, string(yamlBytes))
log.Infof("Executor (version: %s, build_date: %s) initialized (pod: %s/%s) with template:\n%s", version.Version, version.BuildDate, namespace, podName, string(yamlBytes))
return &wfExecutor
}

Expand Down

0 comments on commit 19a34b1

Please sign in to comment.