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 qps/burst flag for k8s client, and provide method to hide these flags #121

Merged
merged 1 commit into from
Dec 9, 2022

Conversation

whitebear009
Copy link
Contributor

related to #105

add qps/burst flag for k8s client, in order to avoid frequent client-side throttle in some scenarios.

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

Welcome @whitebear009!

It looks like this is your first PR to kubernetes-sigs/custom-metrics-apiserver 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/custom-metrics-apiserver has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @whitebear009. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 29, 2022
@olivierlemasle
Copy link
Member

olivierlemasle commented Nov 29, 2022

Thank you @whitebear009

Could you please set the flags' default value?
Cf https://pkg.go.dev/k8s.io/[email protected]/rest#pkg-constants

nit: could you please also update the flags descriptions (including discovery-interval's description) to start with a capital letter (to be consistent with other Kubernetes flags e.g. client-ca-file)?

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 30, 2022
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 30, 2022
@whitebear009
Copy link
Contributor Author

@olivierlemasle has been updated. Please check :)

Copy link
Member

@olivierlemasle olivierlemasle left a comment

Choose a reason for hiding this comment

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

Thank you @whitebear009 👍
/ok-to-test
/lgtm

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 30, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 30, 2022
@olivierlemasle
Copy link
Member

/assign @dgrisonnet

pkg/cmd/builder.go Outdated Show resolved Hide resolved
pkg/cmd/builder.go Outdated Show resolved Hide resolved
@olivierlemasle
Copy link
Member

I remarked that some projects using custom-metrics-apiserver already have flags for QPS / burst (each with their own default values):

@dgrisonnet @whitebear009 What is the way to go for them? Hide the new flags to continue using their own flags?

@dgrisonnet
Copy link
Member

Good catch! Yeah I would expect them to manually hide the new flags (maybe we can provide the method to do that) since migrating would be a breaking change for their CLI options and keeping the new flags around would just duplicate the logic.

Does that sounds right to you @zroubalik?

@whitebear009
Copy link
Contributor Author

whitebear009 commented Dec 1, 2022

@olivierlemasle Good question.
I raised this issue because I found that prometheus-adapter uses the dynamicClient provided by this project, but it does not provide a method to set qps/burst. It seems that keda/crane have not use this kind of method(use their own client), so they can set it through their own flag.

Maybe we can also assign values at initialization in adapter instead of flags in custom-metrics-apiserver.
Take prometheus-adapter as an example:

cmd := &PrometheusAdapter{
		PrometheusURL:         "https://localhost",
		PrometheusVerb:        http.MethodGet,
		MetricsRelistInterval: 10 * time.Minute,
}
cmd.Name = "prometheus-metrics-adapter"
cmd.ClientQPS = 10
cmd.ClientBurst = 5

And then, add qps/burst flag in prometheus-adapter.

If other projects(e.g. keda/crane) need it, they can pass the parameters in the flag to AdapterBase like this. This way no breaking change will occur.

@dgrisonnet
Copy link
Member

Maybe we can also assign values at initialization in adapter instead of flags in custom-metrics-apiserver.
Take prometheus-adapter as an example:

If we go that way then every consumer of the library will have to introduce their own flags which is not ideal, I'd much rather have the library provide the flags since they will enable a functionality actionable at its level.

If other projects(e.g. keda/crane) need it, they can pass the parameters in the flag to AdapterBase like this. This way no breaking change will occur.

There is no immediate breaking changes for the consumers that already have these flags around. They have two options either deprecate their CLI flags in favor of the new ones from the library or just keep using their own implementation and remove the new QPS/burst flags manually.

@dgrisonnet
Copy link
Member

There are still comments to address

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 7, 2022
@whitebear009 whitebear009 changed the title add qps/burst flag for k8s client add qps/burst flag for k8s client, and provide method to hide these flags Dec 7, 2022
@whitebear009
Copy link
Contributor Author

Sorry for the late reply.
I think what you say makes sense, so I provide a bool variable that can manually hide these flags.

Comment on lines 125 to 129
if b.MarkQPSFlagHidden {
// ignore the error if flags does not exist
_ = b.FlagSet.MarkHidden("client-qps")
_ = b.FlagSet.MarkHidden("client-burst")
}
Copy link
Member

Choose a reason for hiding this comment

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

Now that I am seeing it, I feel like we should leave that up to the consumers of the library since at the library level we should always want the QPS flags to be created. Also, in the future we would prefer if our users switched to the new flags instead of their custom ones. wdyt @olivierlemasle?

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with adding ClientQPS and ClientBurst and let users hide the flags if necessary (so no MarkQPSFlagHidden).

I raised the question just to make sure we're aware of this possible flag duplication, but as long as we document the change, I do not see it as an issue.

Copy link
Contributor Author

@whitebear009 whitebear009 Dec 9, 2022

Choose a reason for hiding this comment

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

No problem. I have removed these code.

I raised the #121 (comment) just to make sure we're aware of this possible flag duplication, but as long as we document the change, I do not see it as an issue.

Need I add some documentation in getting-started.md?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! No, we will just mention it in the release note just so that projects consuming this library that already have their own flags are aware that we now also have some as well.

@dgrisonnet
Copy link
Member

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgrisonnet, olivierlemasle, whitebear009

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 Dec 9, 2022
@k8s-ci-robot k8s-ci-robot merged commit cf250a8 into kubernetes-sigs:master Dec 9, 2022
@zroubalik
Copy link
Contributor

Thanks for notifying me about this.

@dgrisonnet dgrisonnet mentioned this pull request May 3, 2023
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants