Skip to content

Commit

Permalink
feat: Identifiable user agents in various Argo commands (#5624)
Browse files Browse the repository at this point in the history
Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>
  • Loading branch information
terrytangyuan committed Apr 8, 2021
1 parent 13fa652 commit b4ce78b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/argo/commands/client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package client

import (
"context"
"fmt"
"os"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

"github.com/argoproj/argo-workflows/v3"
"github.com/argoproj/argo-workflows/v3/pkg/apiclient"
"github.com/argoproj/argo-workflows/v3/util/kubeconfig"
)
Expand Down Expand Up @@ -86,6 +89,8 @@ func GetAuthString() string {
if err != nil {
log.Fatal(err)
}
version := argo.GetVersion()
restConfig = restclient.AddUserAgent(restConfig, fmt.Sprintf("argo-workflows/%s argo-cli", version.Version))
authString, err := kubeconfig.GetAuthString(restConfig, explicitPath)
if err != nil {
log.Fatal(err)
Expand Down
4 changes: 4 additions & 0 deletions cmd/argo/commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import (
"golang.org/x/net/context"
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"
restclient "k8s.io/client-go/rest"
"k8s.io/utils/env"

"github.com/argoproj/argo-workflows/v3"
"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"
wfclientset "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned"
"github.com/argoproj/argo-workflows/v3/server/apiserver"
Expand Down Expand Up @@ -59,6 +61,8 @@ See %s`, help.ArgoSever),
if err != nil {
return err
}
version := argo.GetVersion()
config = restclient.AddUserAgent(config, fmt.Sprintf("argo-workflows/%s argo-server", version.Version))
config.Burst = 30
config.QPS = 20.0

Expand Down
2 changes: 1 addition & 1 deletion cmd/argoexec/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func initExecutor() *executor.WorkflowExecutor {
executorType := os.Getenv(common.EnvVarContainerRuntimeExecutor)
log.WithFields(log.Fields{"version": version, "executorType": executorType}).Info("Starting Workflow Executor")
config, err := clientConfig.ClientConfig()
config = restclient.AddUserAgent(config, fmt.Sprintf("argo-workflows/%s executor/%s", version.Version, executorType))
checkErr(err)
config = restclient.AddUserAgent(config, fmt.Sprintf("argo-workflows/%s argo-executor/%s", version.Version, executorType))

logs.AddK8SLogTransportWrapper(config) // lets log all request as we should typically do < 5 per pod, so this is will show up problems

Expand Down
4 changes: 4 additions & 0 deletions cmd/workflow-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import (

// load authentication plugin for obtaining credentials from cloud providers.
_ "k8s.io/client-go/plugin/pkg/client/auth"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

"github.com/argoproj/argo-workflows/v3"
wfclientset "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned"
cmdutil "github.com/argoproj/argo-workflows/v3/util/cmd"
"github.com/argoproj/argo-workflows/v3/util/logs"
Expand Down Expand Up @@ -71,6 +73,8 @@ func NewRootCommand() *cobra.Command {
if err != nil {
return err
}
version := argo.GetVersion()
config = restclient.AddUserAgent(config, fmt.Sprintf("argo-workflows/%s argo-controller", version.Version))
config.Burst = burst
config.QPS = qps

Expand Down

0 comments on commit b4ce78b

Please sign in to comment.