Skip to content

Improve options handling #123

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

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

olivierlemasle
Copy link
Member

@olivierlemasle olivierlemasle commented Dec 5, 2022

  • Adds option validation
  • Apply Features flags (related to profiling): they were defined but unused
  • Adds the possibility to disable the APIServer's own metrics (however, I did not add a flag for that)
  • Improve code documentation and add tests

Note: this breaks the API compatibility by:

  • removing CustomMetricsAdapterServerOptions.Complete
  • changing CustomMetricsAdapterServerOptions.Validate from func([]string) error to func() error

However, these two functions were empty, so probably unused by downstream implementations. Do you still prefer if I keep the API compatibility ?

/kind feature

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 5, 2022
@k8s-ci-robot
Copy link
Contributor

@olivierlemasle: This issue is currently awaiting triage.

If custom-metrics-apiserver contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 5, 2022
@olivierlemasle olivierlemasle force-pushed the server branch 2 times, most recently from 275418b to bd921ba Compare December 5, 2022 12:51
func (o CustomMetricsAdapterServerOptions) Validate(args []string) error {
return nil
// Validate validates CustomMetricsAdapterServerOptions
func (o CustomMetricsAdapterServerOptions) Validate() error {
Copy link
Member

Choose a reason for hiding this comment

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

Just for the sake of being consistent with the kube-apiserver code, I think it would be better to have a return type of []error

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I used the sample-apiserver as an example (since this file seems to be "forked" from sample-apiserver), and they use this signature:

https://github.com/kubernetes/kubernetes/blob/86f3fa94f1b75da275a8040e4155840a7b473dc1/staging/src/k8s.io/sample-apiserver/pkg/cmd/server/start.go#L102

To which Validate() []error function do you refer?

Copy link
Member

Choose a reason for hiding this comment

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

I was looking at the recommended options code: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/server/options/recommended.go#L158-L172.

Now that you've mention it is coming from the sample-apiserver I am fine with both but would prefer the recommended options approach since custom-metrics-apiserver is a library (similarly to recommended options) and not a complete apiserver.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, it makes sense. Actually, this code came from the sample-apiserver, but it was before the introduction of the builder in 35cf4d7, which changed the way it is used.
I'll update the PR with Validate() []error and ApplyTo.
No problem changing the API between versions?

Copy link
Member

@dgrisonnet dgrisonnet Dec 8, 2022

Choose a reason for hiding this comment

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

No problem changing the API between versions?

It needs to be taken into consideration since it will require users to change their implementation a bit, but still, the behavior will not change a lot, they will just need to update the implementation slightly. As long as it is described in the release note, I am fine with it.

Moreover I am thinking that we should try to bring the resource metrics API over before doing a next release so users will need to do a bit more changes this release compare to others so now should be the best time to unify the implementations IMO

Copy link
Member

Choose a reason for hiding this comment

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

Ok, it makes sense. Actually, this code came from the sample-apiserver, but it was before the introduction of the builder in 35cf4d7, which changed the way it is used.

Make sense to use the newer implementation then.

}

// Config returns configuration for the API server given CustomMetricsAdapterServerOptions
func (o CustomMetricsAdapterServerOptions) Config() (*apiserver.Config, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Since this is meant to be consumed as a library, I would be in favor of updating this method to follow a similar workflow as the options from the kube-apiserver recommended options. The signature would look like:

func (o CustomMetricsAdapterServerOptions) ApplyTo(config *apiserver.Config) error

@olivierlemasle
Copy link
Member Author

Removed the changes related to pprof and EnableMetrics.
I'll address your other comments after clarification about the Validate function.

/remove-kind feature
/kind cleanup

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed kind/feature Categorizes issue or PR as related to a new feature. labels Dec 6, 2022
- Adds validation
- Improve code documentation and add tests
@olivierlemasle
Copy link
Member Author

Pushed a new version to address your comments @dgrisonnet.
I took the opportunity to rename sigs.k8s.io/custom-metrics-apiserver/pkg/cmd/server to sigs.k8s.io/custom-metrics-apiserver/pkg/cmd/options to reflect its new content.

Copy link
Member

@dgrisonnet dgrisonnet left a comment

Choose a reason for hiding this comment

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

Nice!

/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 8, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 8, 2022
@k8s-ci-robot k8s-ci-robot merged commit 28a0c93 into kubernetes-sigs:master Dec 8, 2022
@olivierlemasle olivierlemasle deleted the server branch December 8, 2022 19:35
@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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants