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
Fallback to legacy discovery on a wider range of conditions #119870
Conversation
Please note that we're already in Test Freeze for the Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Wed Aug 9 16:32:55 UTC 2023. |
staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery.go
Outdated
Show resolved
Hide resolved
22582e1
to
f8d6e7a
Compare
staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery.go
Outdated
Show resolved
Hide resolved
/assign @liggitt |
/triage accepted |
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.
mostly lgtm
staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery_test.go
Show resolved
Hide resolved
staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery.go
Outdated
Show resolved
Hide resolved
f8d6e7a
to
b170fa8
Compare
169cb55
to
7fc9bab
Compare
staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_discovery.go
Outdated
Show resolved
Hide resolved
@@ -217,8 +219,7 @@ func (dm *discoveryManager) fetchFreshDiscoveryForService(gv metav1.GroupVersion | |||
writer := newInMemoryResponseWriter() | |||
handler.ServeHTTP(writer, req) | |||
|
|||
switch writer.respCode { |
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 think a switch might still be more readable here
switch {
case writer.respCode == http.StatusNotModified:
// ...cache case
case writer.respCode == http.StatusServiceUnavailable:
// ...server unavailable
case writer.respCode == http.StatusOK && discovery.ContentTypeIsGVK(writer.Header().Get("Content-Type"), ...):
// ...aggregated
default:
// ...fallback to legacy
}
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.
Since discovery.ContentTypeIsGVK(...)
returns two values, the condition would need to be checked outside the case statement. Eg:
isGVK, err := discovery.ContentTypeIsGVK(...)
switch {
case ...
case writer.respCode == http.StatusOK && isGVK && err == nil:
// ...aggregated
...
}
Wouldn't an if statement be slightly cleaner in this regard?
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.
heh, true
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.
Changed to a case statement with the GVK check outside of it, lmk if this is readable.
/priority important-soon |
/kind regression |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Jefftree, liggitt 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 |
…9870-upstream-release-1.27 Automated cherry pick of #119870: Fallback to legacy discovery on a wider range of conditions
…9870-upstream-release-1.28 Automated cherry pick of #119870: Fallback to legacy discovery on a wider range of conditions
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
* Update to v1.28.2 Signed-off-by: Johnatas <johnatasr@hotmail.com> * Bump containerd and stargz versions Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Print message on upgrade fail Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Send Bad Gateway instead of Service Unavailable when tunnel dial fails Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Add 60 seconds to server upgrade wait to account for delays in apiserver readiness Also change cleanup helper to ensure upgrade test doesn't pollute the images for the rest of the tests. Signed-off-by: Brad Davidson <brad.davidson@rancher.com> --------- Signed-off-by: Johnatas <johnatasr@hotmail.com> Signed-off-by: Brad Davidson <brad.davidson@rancher.com> Co-authored-by: Brad Davidson <brad.davidson@rancher.com>
* Update to v1.27.6 Signed-off-by: Pedro Tashima <pedro.tashima@suse.com> * Bump containerd and stargz versions Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Print message on upgrade fail Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Send Bad Gateway instead of Service Unavailable when tunnel dial fails Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Add 60 seconds to server upgrade wait to account for delays in apiserver readiness Also change cleanup helper to ensure upgrade test doesn't pollute the images for the rest of the tests. Signed-off-by: Brad Davidson <brad.davidson@rancher.com> --------- Signed-off-by: Pedro Tashima <pedro.tashima@suse.com> Signed-off-by: Brad Davidson <brad.davidson@rancher.com> Co-authored-by: Pedro Tashima <pedro.tashima@suse.com> Co-authored-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
* Update to v1.26.9 Signed-off-by: Johnatas <johnatasr@hotmail.com> * Bump containerd and stargz versions Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Print message on upgrade fail Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Send Bad Gateway instead of Service Unavailable when tunnel dial fails Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> * Add 60 seconds to server upgrade wait to account for delays in apiserver readiness Also change cleanup helper to ensure upgrade test doesn't pollute the images for the rest of the tests. Signed-off-by: Brad Davidson <brad.davidson@rancher.com> --------- Signed-off-by: Johnatas <johnatasr@hotmail.com> Signed-off-by: Brad Davidson <brad.davidson@rancher.com> Co-authored-by: Brad Davidson <brad.davidson@rancher.com>
Works around new handling for Service Unavailable by apiserver aggregation added in kubernetes/kubernetes#119870 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> porting by Signed-off-by: Deshi Xiao <xiaods@gmail.com>
/kind bug
What this PR does / why we need it:
Fallback to legacy discovery if Aggregated Discovery query was unsuccessful. This includes other response codes than 406, and missing/incorrect content-type headers.
Which issue(s) this PR fixes:
Fixes #119662
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: