-
Notifications
You must be signed in to change notification settings - Fork 1.2k
✨ Add UserAgentID option to the manager #2506
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
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: m-messiah The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
// UserAgentID is the name of the manager to represent itself in the client requests. | ||
// | ||
// If set, the UserAgentID will be used to override the first part of rest.DefaultKubernetesUserAgent() | ||
UserAgentID string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the advantage of this over setting it in the rest config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In comparison to rest.Config this thing has two big advantages I see:
- It re-uses DefaultKubernetesUserAgent, having the same structure and versioning as it was before, but with fixed os.Args[0] part.
- It allows an operator to continue using
manager.New(config.GetConfigOrDie(), opts)
, without additional thoughts about UserAgent manipulation, but setting the ID in the Options.
Generally speaking, I'd think having the field named as Name
or ClientName
would be better and could be reused somewhere in the futuer, but don't see where it could be reused just now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It re-uses DefaultKubernetesUserAgent, having the same structure and versioning as it was before, but with fixed os.Args[0] part.
I don't know what that means because I don't know how the default looks like. Why does it matter to re-use the same structure and versioning rather than setting the entire user-agent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, DefaultKubernetesUserAgent is the useragent like: manager/v1.0.1 (linux/amd64) kubernetes/12312afdb
, where we have os.Args[0] + version + runtime.Os/arch + git hash.
So in the way of keep version and runtime the solution is to cut off the first part and replace it with correct name, rather than requiring operator to re-construct the whole UserAgent string with version and runtime lookups.
The better way to achieve it is to have a name param to client-go DefaultKubernetesUserAgent (or have the similar method) and set the UserAgent explicitely, but it is out of scope of controller-runtime.. But yes, I think I'd better do a PR to client-go, as it makes more sense there
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
The PR is intended to solve issue #1215, allowing passing the new
Option
to the controller-manager constructor to override the first part of the UserAgent (as it was suggested in #1215 (comment))The solution is pretty safe as it does not change the
UserAgent
if it was already set in therest.Config
provided, but override it only whenrest.DefaultKubernetesUserAgent()
is used (which is alwaysmanager/<version> ...
)Manipulation of UserAgent broke the test, initially created as part of #1401, but the test does not make sense anymore as:
rest.Config
cluster.New()
.