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

Add Anthos MultiCloud distributions to UserAgentMode #465

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion pkg/export/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const (
UAModeUnspecified = "unspecified"
UAModeAVMW = "on-prem"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add comments on what each of these modes means? e.g. what's the difference between "on-prem" and "baremetal"?

UAModeABM = "baremetal"
UAModeAWS = "aws"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have both a UserAgentMode and UserAgentEnv, where the former is generally reserved for the mode of installation and the latter for the platform environment. Notably, the former is user-modifiable via a flag, whereas the latter is hard-coded into the binary and auto-populated at runtime.

Is there any way to auto-detect whether we're running in AWS or Azure using a go library that we could add to the logic in setup.go?

For on-prem or baremetal, autodetection is not possible due to the heterogeneity of those environments, so using "mode" as a way to distinguish these makes sense, albeit it's getting double-usage out of that flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. @ericroman920 could you comment on the auto detection for anthos on aws & azure?

UAModeAzure = "azure"
UAModeAttached = "attached"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "attached"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attached clusters could be any k8s cluster that customers want to connect to Google.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha - could you add a comment?

)

// Environment variable that contains additional command line arguments.
Expand Down Expand Up @@ -133,7 +136,7 @@ func FromFlags(a *kingpin.Application, userAgentProduct string) func(log.Logger,
a.Flag("export.label.project-id", fmt.Sprintf("Default project ID set for all exported data. Prefer setting the external label %q in the Prometheus configuration if not using the auto-discovered default.", export.KeyProjectID)).
Default(opts.ProjectID).StringVar(&opts.ProjectID)

a.Flag("export.user-agent-mode", fmt.Sprintf("Mode for user agent used for requests against the GCM API. Valid values are %q, %q, %q, %q or %q.", UAModeGKE, UAModeKubectl, UAModeAVMW, UAModeABM, UAModeUnspecified)).
a.Flag("export.user-agent-mode", fmt.Sprintf("Mode for user agent used for requests against the GCM API. Valid values are %q, %q, %q, %q, %q, %q, %q or %q.", UAModeGKE, UAModeKubectl, UAModeAVMW, UAModeABM, UAModeAWS, UAModeAzure, UAModeAttached, UAModeUnspecified)).
Default("unspecified").EnumVar(&opts.UserAgentMode, UAModeUnspecified, UAModeGKE, UAModeKubectl, UAModeAVMW, UAModeABM)

// The location and cluster flag should probably not be used. On the other hand, they make it easy
Expand Down