-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Support backwards compatibility for v1beta1 custom metrics client #68015
Conversation
/assign @DirectXMan12 |
@kubernetes/sig-autoscaling-pr-reviews |
445809c
to
02ed29f
Compare
/approve |
/milestone 1.12 |
@DirectXMan12: The provided milestone is not valid for this repository. Milestones in this repository: [ Use In response to this:
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. |
/milestone v1.12 |
@@ -237,13 +275,13 @@ func (m *namespacedMetrics) GetForObjects(groupKind schema.GroupKind, selector l | |||
return nil, err | |||
} | |||
|
|||
res := &v1beta2.MetricValueList{} | |||
res := &v1beta1.MetricValueList{} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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".
02ed29f
to
161caa3
Compare
/ok-to-test |
/retest |
/hold while we figure out what's going on |
/hold |
/cc @wenjiaswe |
f519a94
to
160eb6e
Compare
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.
160eb6e
to
76bd48b
Compare
controller changes look ok. You'll need an api-approver to put the API back. /approve |
/approve API changes to optional |
/lgtm |
[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 |
/retest |
/test pull-kubernetes-e2e-kops-aws |
1 similar comment
/test pull-kubernetes-e2e-kops-aws |
@luxas looks like this needs a release note? |
@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. |
@DirectXMan12 gotcha, thanks for the update! |
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.
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: