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

Support backwards compatibility for v1beta1 custom metrics client #68015

Merged
merged 2 commits into from
Sep 10, 2018

Conversation

damemi
Copy link
Contributor

@damemi damemi commented Aug 29, 2018

Fixes #68011. The custom metrics client was updated to expect v1beta2 which broke all existing adapters. This reverts that change and adds a conversion from v1beta1 to v1beta2 internally

What this PR does / why we need it:
Fixes a bug in #64097 which broke custom_metrics clients for adapters using v1beta1

Which issue(s) this PR fixes
Fixes #68011

Special notes for your reviewer:

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 29, 2018
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 29, 2018
@damemi
Copy link
Contributor Author

damemi commented Aug 29, 2018

/assign @DirectXMan12

@DirectXMan12
Copy link
Contributor

@kubernetes/sig-autoscaling-pr-reviews

@k8s-ci-robot k8s-ci-robot added the sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling. label Aug 29, 2018
@damemi damemi force-pushed the hpa-metrics-specificity branch 2 times, most recently from 445809c to 02ed29f Compare August 29, 2018 16:21
@DirectXMan12
Copy link
Contributor

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 29, 2018
@DirectXMan12
Copy link
Contributor

/milestone 1.12

@k8s-ci-robot
Copy link
Contributor

@DirectXMan12: The provided milestone is not valid for this repository. Milestones in this repository: [next-candidate, v1.10, v1.11, v1.12, v1.13, v1.4, v1.5, v1.6, v1.7, v1.8, v1.9]

Use /milestone clear to clear the milestone.

In response to this:

/milestone 1.12

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.

@DirectXMan12
Copy link
Contributor

/milestone v1.12

@k8s-ci-robot k8s-ci-robot added this to the v1.12 milestone Aug 29, 2018
@@ -237,13 +275,13 @@ func (m *namespacedMetrics) GetForObjects(groupKind schema.GroupKind, selector l
return nil, err
}

res := &v1beta2.MetricValueList{}
res := &v1beta1.MetricValueList{}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really understand REST client machinery well enough, so I may very well be wrong on this, but won't this cause the following call to fail for an adapter that actually implements v1beta2?

We initially put the result into v1beta1.MetricValueList{} and only later apply the conversion. But I don't expect v1beta2 result to be able to deserialize into a v1beta1 value list as MetricValue type is not compatible between versions. Am I missing something here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Adapters will have to implement both APIs for the time being, and then we'll have to do the switch over in a later release.

So adapters should start implementing v1beta2 now, then when we switch over next release (or the one after) here, they'll have support for it, and a given adapter will work with both versions of kube. Then, the release after that, we'll be able to finally remove v1beta1.

(that's the only way I can see this working, without fallback logic, and I don't think there's a precedence for fallback logic since we stopped using unversioned clients).

Copy link
Contributor

Choose a reason for hiding this comment

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

I see your point. I wonder if we could address this by having a separate client for each version, discover which version is available and use the appropriate client in HPA?

I don't like the approach of switching the version at some point, mainly because I'm skeptical about every adapter implementing v1beta2 while it's not actually supported by k8s. I think we're effectively just pushing the problem to next release.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also our deprecation policy is to support deprecated beta for 3 versions, so it will take a while to switch over. In the meantime every new adapter would have to implement a deprecated API.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see your point. I wonder if we could address this by having a separate client for each version, discover which version is available and use the appropriate client in HPA?

I considered that, but it's way more complicated, and doesn't really seem to have a precendent in the rest of the codebase, IIRC (ever since we removed the unversioned clients).

In the meantime every new adapter would have to implement a deprecated API.

Nobody needs to implement anything new except for the developers of kubernetes-incubator/custom-metrics-apiserver -- all adapters should get the APIs for free when they update.

Perhaps we should have @kubernetes/sig-api-machinery-pr-reviews weigh in?

Copy link
Contributor

Choose a reason for hiding this comment

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

if we really want to reintroduce hubbed clients, I'm very hesitant to do so during code slush -- I'd really prefer to go with this solution, which should produce a working cluster, and then deal with potentially adding hubbed clients next release.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lavalamp another concrete example of the utility of a hub an a hubbed client.

@DirectXMan12 if it were my code, I would generate two different clients. Then given an apiserver, I would use discovery to choose from the available APIs to new up the "best" client. Then, if necessary, I would provide adapter clients that could skin one version as another one. It's pretty painful, but with only two versions, it isn't so bad.

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k ack, that seems reasonable to me eventually. do we want to try to do it less than a week before code freeze while the tests are broken, though?

@damemi your mission, should you choose to accept it ^

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k ack, that seems reasonable to me eventually. do we want to try to do it less than a week before code freeze while the tests are broken, though?

This is a regression fix, right? If this regressed, then we'll certainly take a fix after freeze. Things like this are rarely re-visited after they "work".

@damemi damemi force-pushed the hpa-metrics-specificity branch from 02ed29f to 161caa3 Compare August 29, 2018 17:47
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 29, 2018
@DirectXMan12
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 29, 2018
@DirectXMan12
Copy link
Contributor

/retest

@DirectXMan12
Copy link
Contributor

/hold while we figure out what's going on

@DirectXMan12
Copy link
Contributor

/hold

@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 Aug 30, 2018
@fedebongio
Copy link
Contributor

/cc @wenjiaswe

@damemi damemi force-pushed the hpa-metrics-specificity branch from f519a94 to 160eb6e Compare September 6, 2018 19:08
@k8s-ci-robot k8s-ci-robot added sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Sep 6, 2018
damemi and others added 2 commits September 6, 2018 15:20
This changes the custom metrics client logic over to support multiple versions
of the custom metrics API by checking discovery to find the appropriate versions.

Fixes kubernetes#68011

Co-authored-by: Solly Ross <sross@redhat.com>
There were a few cases where fields that should have been marked optional
were not.  This was causing weird validation issues, but is now fixed.
@damemi damemi force-pushed the hpa-metrics-specificity branch from 160eb6e to 76bd48b Compare September 6, 2018 19:21
@DirectXMan12
Copy link
Contributor

/hold cancel
/remove-sig network

@deads2k or @lavalamp PTAL for the rest of the approvals

@k8s-ci-robot k8s-ci-robot removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. sig/network Categorizes an issue or PR as relevant to SIG Network. labels Sep 6, 2018
@deads2k
Copy link
Contributor

deads2k commented Sep 10, 2018

controller changes look ok. You'll need an api-approver to put the API back.

/approve

@smarterclayton
Copy link
Contributor

/approve

API changes to optional

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2018
@DirectXMan12
Copy link
Contributor

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: damemi, deads2k, DirectXMan12, smarterclayton

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

@damemi
Copy link
Contributor Author

damemi commented Sep 10, 2018

/retest

@damemi
Copy link
Contributor Author

damemi commented Sep 10, 2018

/test pull-kubernetes-e2e-kops-aws

1 similar comment
@damemi
Copy link
Contributor Author

damemi commented Sep 10, 2018

/test pull-kubernetes-e2e-kops-aws

@k8s-ci-robot k8s-ci-robot merged commit 99f3195 into kubernetes:master Sep 10, 2018
@nikhita
Copy link
Member

nikhita commented Sep 12, 2018

@luxas looks like this needs a release note?

@DirectXMan12
Copy link
Contributor

@nikhita no, it shouldn't since it's a fix for an unintentional issue introduced in a previous PR this release. This now works as noted in the original PR's release note.

@nikhita
Copy link
Member

nikhita commented Sep 12, 2018

@DirectXMan12 gotcha, thanks for the update!

x13n added a commit to x13n/kubernetes that referenced this pull request Sep 27, 2018
They were broken probably by kubernetes#68015
that introduced a REST mapper which doesn't contain a mapping for Pod
resource, yet the test is depending on it.
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/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HPA no longer works with adapters exposing Custom Metrics v1beta1 API
9 participants