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

🌱 chore: use capo cluster agent for API requests #1614

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

mnaser
Copy link
Contributor

@mnaser mnaser commented Jul 20, 2023

What this PR does / why we need it:
At the moment, we do not modify the user agent for all API requests we make which make it hard to identify if certain requests were done by CAPO or not.

This change prepends the CAPO version to the Gophercloud user agent which will give plenty of benefits.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1611

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • if necessary:
    • includes documentation
    • adds unit tests

/hold

At the moment, we do not modify the user agent for all API requests
we make which make it hard to identify if certain requests were
done by CAPO or not.

This change prepends the CAPO version to the Gophercloud user
agent which will give plenty of benefits.
@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 20, 2023
@netlify
Copy link

netlify bot commented Jul 20, 2023

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit 21e6323
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/64b8ad399bddc20008a25e99
😎 Deploy Preview https://deploy-preview-1614--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 20, 2023
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 20, 2023
@jichenjc
Copy link
Contributor

/lgtm

make paste the updated output will be informative

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 20, 2023
Copy link
Contributor

@mdbooth mdbooth left a comment

Choose a reason for hiding this comment

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

This looks great. Unfortunately we don't currently set the version in our builds, so we're going to have to fix that too.

For an example of how this is done see: https://github.com/kubernetes/cloud-provider-openstack/blob/b229f849774e7e1976256faf2df4931841d242fa/Makefile#L39

@mnaser
Copy link
Contributor Author

mnaser commented Jul 20, 2023

@mdbooth ... i think we do..?

https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/Makefile#L114-L115

though i haven't really validated here.

@mdbooth
Copy link
Contributor

mdbooth commented Jul 20, 2023

@mdbooth ... i think we do..?

https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/Makefile#L114-L115

though i haven't really validated here.

I didn't know that was there!

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mdbooth, mnaser

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 20, 2023
@@ -152,6 +153,10 @@ func NewProviderClient(cloud clientconfig.Cloud, caCert []byte, logger logr.Logg
return nil, nil, "", fmt.Errorf("create providerClient err: %v", err)
}

ua := gophercloud.UserAgent{}
ua.Prepend(fmt.Sprintf("cluster-api-provider-openstack/%s", version.Get().String()))
Copy link
Contributor

@stephenfin stephenfin Jul 28, 2023

Choose a reason for hiding this comment

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

Is there benefit in using the default user agent and simply prepending to it, e.g.

provider.UserAgent.Prepend(fmt.Sprintf("cluster-api-provider-openstack/%s", version.Get().String()))

That way we'll also get the gophercloud version in use. Perhaps that's overkill...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally I mimicked the patter that was used by the CPO so that's how I got where I got.

@mnaser
Copy link
Contributor Author

mnaser commented Aug 2, 2023

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 2, 2023
@k8s-ci-robot k8s-ci-robot merged commit 3c742d2 into kubernetes-sigs:main Aug 2, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use reasonable User-Agent for requests
5 participants