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 UserAgentID option to the manager #2506

Closed

Conversation

m-messiah
Copy link
Member

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 the rest.Config provided, but override it only when rest.DefaultKubernetesUserAgent() is used (which is always manager/<version> ...)

Manipulation of UserAgent broke the test, initially created as part of #1401, but the test does not make sense anymore as:

  1. LeaderElectionConfig is created as the copy of rest.Config
  2. We manipulate UserAgent always if it is empty, it was done after the original config was assigned to the cluster.New().

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 22, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: m-messiah
Once this PR has been reviewed and has the lgtm label, please assign vincepri for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

// 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
Copy link
Member

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?

Copy link
Member Author

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:

  1. It re-uses DefaultKubernetesUserAgent, having the same structure and versioning as it was before, but with fixed os.Args[0] part.
  2. 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.

Copy link
Member

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?

Copy link
Member Author

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

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 21, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 20, 2024
@k8s-triage-robot
Copy link

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:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

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:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants