mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
stop registering the same group multiple times
This commit is contained in:
parent
a8409af5b5
commit
23b22d645e
@ -21,6 +21,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
genericapifilters "k8s.io/apiserver/pkg/endpoints/filters"
|
genericapifilters "k8s.io/apiserver/pkg/endpoints/filters"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
@ -69,6 +70,8 @@ type APIAggregator struct {
|
|||||||
|
|
||||||
// proxyHandlers are the proxy handlers that are currently registered, keyed by apiservice.name
|
// proxyHandlers are the proxy handlers that are currently registered, keyed by apiservice.name
|
||||||
proxyHandlers map[string]*proxyHandler
|
proxyHandlers map[string]*proxyHandler
|
||||||
|
// handledGroups are the groups that already have routes
|
||||||
|
handledGroups sets.String
|
||||||
|
|
||||||
// lister is used to add group handling for /apis/<group> aggregator lookups based on
|
// lister is used to add group handling for /apis/<group> aggregator lookups based on
|
||||||
// controller state
|
// controller state
|
||||||
@ -131,6 +134,7 @@ func (c completedConfig) New() (*APIAggregator, error) {
|
|||||||
proxyClientCert: c.ProxyClientCert,
|
proxyClientCert: c.ProxyClientCert,
|
||||||
proxyClientKey: c.ProxyClientKey,
|
proxyClientKey: c.ProxyClientKey,
|
||||||
proxyHandlers: map[string]*proxyHandler{},
|
proxyHandlers: map[string]*proxyHandler{},
|
||||||
|
handledGroups: sets.String{},
|
||||||
lister: informerFactory.Apiregistration().InternalVersion().APIServices().Lister(),
|
lister: informerFactory.Apiregistration().InternalVersion().APIServices().Lister(),
|
||||||
serviceLister: kubeInformers.Core().V1().Services().Lister(),
|
serviceLister: kubeInformers.Core().V1().Services().Lister(),
|
||||||
endpointsLister: kubeInformers.Core().V1().Endpoints().Lister(),
|
endpointsLister: kubeInformers.Core().V1().Endpoints().Lister(),
|
||||||
@ -233,6 +237,11 @@ func (s *APIAggregator) AddAPIService(apiService *apiregistration.APIService) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we've already registered the path with the handler, we don't want to do it again.
|
||||||
|
if s.handledGroups.Has(apiService.Spec.Group) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// it's time to register the group aggregation endpoint
|
// it's time to register the group aggregation endpoint
|
||||||
groupPath := "/apis/" + apiService.Spec.Group
|
groupPath := "/apis/" + apiService.Spec.Group
|
||||||
groupDiscoveryHandler := &apiGroupHandler{
|
groupDiscoveryHandler := &apiGroupHandler{
|
||||||
@ -244,7 +253,7 @@ func (s *APIAggregator) AddAPIService(apiService *apiregistration.APIService) {
|
|||||||
// aggregation is protected
|
// aggregation is protected
|
||||||
s.GenericAPIServer.HandlerContainer.UnlistedRoutes.Handle(groupPath, groupDiscoveryHandler)
|
s.GenericAPIServer.HandlerContainer.UnlistedRoutes.Handle(groupPath, groupDiscoveryHandler)
|
||||||
s.GenericAPIServer.HandlerContainer.UnlistedRoutes.Handle(groupPath+"/", groupDiscoveryHandler)
|
s.GenericAPIServer.HandlerContainer.UnlistedRoutes.Handle(groupPath+"/", groupDiscoveryHandler)
|
||||||
|
s.handledGroups.Insert(apiService.Spec.Group)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveAPIService removes the APIService from being handled. Later on it will disable the proxy endpoint.
|
// RemoveAPIService removes the APIService from being handled. Later on it will disable the proxy endpoint.
|
||||||
|
1
vendor/BUILD
vendored
1
vendor/BUILD
vendored
@ -16453,6 +16453,7 @@ go_library(
|
|||||||
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
||||||
"//vendor:k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
"//vendor:k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
||||||
"//vendor:k8s.io/apimachinery/pkg/util/runtime",
|
"//vendor:k8s.io/apimachinery/pkg/util/runtime",
|
||||||
|
"//vendor:k8s.io/apimachinery/pkg/util/sets",
|
||||||
"//vendor:k8s.io/apimachinery/pkg/util/wait",
|
"//vendor:k8s.io/apimachinery/pkg/util/wait",
|
||||||
"//vendor:k8s.io/apiserver/pkg/endpoints/filters",
|
"//vendor:k8s.io/apiserver/pkg/endpoints/filters",
|
||||||
"//vendor:k8s.io/apiserver/pkg/endpoints/handlers/responsewriters",
|
"//vendor:k8s.io/apiserver/pkg/endpoints/handlers/responsewriters",
|
||||||
|
Loading…
Reference in New Issue
Block a user