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

ROX-8277 Fix malformed operator k8s client user-agent #5307

Closed
wants to merge 3 commits into from

Conversation

ludydoo
Copy link
Contributor

@ludydoo ludydoo commented Mar 20, 2023

Description

In certain cases, the UserAgent string sent by the operator to the kubernetes API is malformed. e.g.

"userAgent": "stackrox-operator/v0.0.0 (linux/amd64) kubernetes/$Format/leader-election"

^ see the $Format/... suffix

It seems that the operator controller-runtime k8s client config is not used for all clients. For example, it seems that there is another k8s client instantiated for the leader election, which does not use the specified userAgent.

@ludydoo ludydoo requested a review from a team as a code owner March 20, 2023 11:15
@roxbot
Copy link
Contributor

roxbot commented Mar 20, 2023

Images are ready for the commit at 01f56e5.

To use with deploy scripts, first export MAIN_IMAGE_TAG=3.74.x-420-g189ebf34c8.

@ludydoo ludydoo closed this Mar 20, 2023
@ludydoo
Copy link
Contributor Author

ludydoo commented Mar 20, 2023

Closing as it is not currently possible to configure the leader-election user agent. kubernetes-sigs/controller-runtime#2243

@porridge
Copy link
Contributor

How about fixing it upstream?

@ludydoo
Copy link
Contributor Author

ludydoo commented Mar 21, 2023

@porridge yeah I can look at that. I see two issues

  1. The client-go AddUserAgent not "adding an user agent", but ignoring a pre-existing user agent and using DefaultKubernetesUserAgent() + "/" + <whatever>
  2. The controller-runtime ignoring the LeaderElectionConfig: rest.Config.UserAgent configuration.
  3. Perhaps even that the NewClient config option (doc says that it's used to create a new rest.Client) is also ignored in the case of the Leader Election client.

@ludydoo
Copy link
Contributor Author

ludydoo commented Mar 21, 2023

k8s-client PR: kubernetes/kubernetes#116801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants