Skip to content

Commit

Permalink
feat: Add identifiable user agents in various Argo commands (argoproj…
Browse files Browse the repository at this point in the history
…#8566)

Signed-off-by: Yuan Tang <[email protected]>
  • Loading branch information
terrytangyuan authored Feb 25, 2022
1 parent 76eddaf commit a02f35e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func NewCommand() *cobra.Command {
config, err := clientConfig.ClientConfig()
errors.CheckError(err)
errors.CheckError(v1alpha1.SetK8SConfigDefaults(config))
vers := common.GetVersion()
config.UserAgent = fmt.Sprintf("argocd-application-controller/%s (%s)", vers.Version, vers.Platform)

kubeClient := kubernetes.NewForConfigOrDie(config)
appClient := appclientset.NewForConfigOrDie(config)
Expand Down Expand Up @@ -136,7 +138,6 @@ func NewCommand() *cobra.Command {
errors.CheckError(err)
cacheutil.CollectMetrics(redisClient, appController.GetMetricsServer())

vers := common.GetVersion()
log.Infof("Application Controller (version: %s, built: %s) starting (namespace: %s)", vers.Version, vers.BuildDate, namespace)
stats.RegisterStackDumper()
stats.StartStatsTicker(10 * time.Minute)
Expand Down
5 changes: 5 additions & 0 deletions cmd/argocd-dex/commands/argocd_dex.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"os/exec"
"syscall"

"github.com/argoproj/argo-cd/v2/common"

"github.com/ghodss/yaml"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -56,9 +58,12 @@ func NewRunDexCommand() *cobra.Command {
errors.CheckError(err)
config, err := clientConfig.ClientConfig()
errors.CheckError(err)
vers := common.GetVersion()
config.UserAgent = fmt.Sprintf("argocd-dex/%s (%s)", vers.Version, vers.Platform)
namespace, _, err := clientConfig.Namespace()
errors.CheckError(err)
kubeClientset := kubernetes.NewForConfigOrDie(config)

settingsMgr := settings.NewSettingsManager(context.Background(), kubeClientset, namespace)
prevSettings, err := settingsMgr.GetSettings()
errors.CheckError(err)
Expand Down
6 changes: 5 additions & 1 deletion cmd/argocd-notification/commands/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
"os"
"strings"

"github.com/argoproj/argo-cd/v2/common"

service "github.com/argoproj/argo-cd/v2/util/notification/argocd"

notificationscontroller "github.com/argoproj/argo-cd/v2/notification_controller/controller"

controller "github.com/argoproj/notifications-engine/pkg/controller"
"github.com/argoproj/notifications-engine/pkg/controller"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -59,6 +61,8 @@ func NewCommand() *cobra.Command {
if err != nil {
return err
}
vers := common.GetVersion()
restConfig.UserAgent = fmt.Sprintf("argocd-notifications-controller/%s (%s)", vers.Version, vers.Platform)
dynamicClient, err := dynamic.NewForConfig(restConfig)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions cmd/argocd-server/commands/argocd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func NewCommand() *cobra.Command {
appclientsetConfig, err := clientConfig.ClientConfig()
errors.CheckError(err)
errors.CheckError(v1alpha1.SetK8SConfigDefaults(appclientsetConfig))
vers := common.GetVersion()
config.UserAgent = fmt.Sprintf("argocd-server/%s (%s)", vers.Version, vers.Platform)

if failureRetryCount > 0 {
appclientsetConfig = kube.AddFailureRetryWrapper(appclientsetConfig, failureRetryCount, failureRetryPeriodMilliSeconds)
Expand Down

0 comments on commit a02f35e

Please sign in to comment.