mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
fix aggregated discovery legacy fallback
due to redesign where we changed from new endpoint to /apis. The expected error was not also changed. Caught by e2e tests when feature enabled. Should have been caught by unit test first but it was implemented without root /apis. Unit test also fixed
This commit is contained in:
parent
b2c72feca8
commit
1550655336
@ -232,7 +232,7 @@ func (dm *discoveryManager) fetchFreshDiscoveryForService(gv metav1.GroupVersion
|
|||||||
|
|
||||||
dm.setCacheEntryForService(info.service, cached)
|
dm.setCacheEntryForService(info.service, cached)
|
||||||
return &cached, nil
|
return &cached, nil
|
||||||
case http.StatusNotFound:
|
case http.StatusNotAcceptable:
|
||||||
// Discovery Document is not being served at all.
|
// Discovery Document is not being served at all.
|
||||||
// Fall back to legacy discovery information
|
// Fall back to legacy discovery information
|
||||||
if len(gv.Version) == 0 {
|
if len(gv.Version) == 0 {
|
||||||
|
@ -205,6 +205,7 @@ func TestRemoveAPIService(t *testing.T) {
|
|||||||
|
|
||||||
func TestLegacyFallback(t *testing.T) {
|
func TestLegacyFallback(t *testing.T) {
|
||||||
aggregatedResourceManager := discoveryendpoint.NewResourceManager()
|
aggregatedResourceManager := discoveryendpoint.NewResourceManager()
|
||||||
|
rootAPIsHandler := discovery.NewRootAPIsHandler(discovery.DefaultAddresses{DefaultAddress: "192.168.1.1"}, scheme.Codecs)
|
||||||
|
|
||||||
legacyGroupHandler := discovery.NewAPIGroupHandler(scheme.Codecs, metav1.APIGroup{
|
legacyGroupHandler := discovery.NewAPIGroupHandler(scheme.Codecs, metav1.APIGroup{
|
||||||
Name: "stable.example.com",
|
Name: "stable.example.com",
|
||||||
@ -262,9 +263,11 @@ func TestLegacyFallback(t *testing.T) {
|
|||||||
} else if r.URL.Path == "/apis/stable.example.com/v1" {
|
} else if r.URL.Path == "/apis/stable.example.com/v1" {
|
||||||
// defer to legacy discovery
|
// defer to legacy discovery
|
||||||
legacyResourceHandler.ServeHTTP(w, r)
|
legacyResourceHandler.ServeHTTP(w, r)
|
||||||
|
} else if r.URL.Path == "/apis" {
|
||||||
|
rootAPIsHandler.ServeHTTP(w, r)
|
||||||
} else {
|
} else {
|
||||||
// Unknown url
|
// Unknown url
|
||||||
w.WriteHeader(http.StatusNotFound)
|
t.Fatalf("unexpected request sent to %v", r.URL.Path)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
testCtx, cancel := context.WithCancel(context.Background())
|
testCtx, cancel := context.WithCancel(context.Background())
|
||||||
|
Loading…
Reference in New Issue
Block a user