mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
feat: remove EnableAggregatedDiscoveryTimeout feature gate
This commit is contained in:
parent
7bc8c70f20
commit
14dc59ee54
@ -50,7 +50,6 @@ import (
|
|||||||
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1"
|
informers "k8s.io/kube-aggregator/pkg/client/informers/externalversions/apiregistration/v1"
|
||||||
"k8s.io/kube-aggregator/pkg/controllers/autoregister"
|
"k8s.io/kube-aggregator/pkg/controllers/autoregister"
|
||||||
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
||||||
kubefeatures "k8s.io/kubernetes/pkg/features"
|
|
||||||
"k8s.io/kubernetes/pkg/master/controller/crdregistration"
|
"k8s.io/kubernetes/pkg/master/controller/crdregistration"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -110,11 +109,10 @@ func createAggregatorConfig(
|
|||||||
SharedInformerFactory: externalInformers,
|
SharedInformerFactory: externalInformers,
|
||||||
},
|
},
|
||||||
ExtraConfig: aggregatorapiserver.ExtraConfig{
|
ExtraConfig: aggregatorapiserver.ExtraConfig{
|
||||||
ProxyClientCert: certBytes,
|
ProxyClientCert: certBytes,
|
||||||
ProxyClientKey: keyBytes,
|
ProxyClientKey: keyBytes,
|
||||||
ServiceResolver: serviceResolver,
|
ServiceResolver: serviceResolver,
|
||||||
ProxyTransport: proxyTransport,
|
ProxyTransport: proxyTransport,
|
||||||
EnableAggregatedDiscoveryTimeout: utilfeature.DefaultFeatureGate.Enabled(kubefeatures.EnableAggregatedDiscoveryTimeout),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,13 +482,6 @@ const (
|
|||||||
//
|
//
|
||||||
// Enables the startupProbe in kubelet worker.
|
// Enables the startupProbe in kubelet worker.
|
||||||
StartupProbe featuregate.Feature = "StartupProbe"
|
StartupProbe featuregate.Feature = "StartupProbe"
|
||||||
|
|
||||||
// owner @deads2k
|
|
||||||
// deprecated: v1.16
|
|
||||||
//
|
|
||||||
// Enable the aggregated discovery timeout to ensure client responsiveness. Note this feature is present
|
|
||||||
// only for backward compatibility, it will be removed in the 1.17 release.
|
|
||||||
EnableAggregatedDiscoveryTimeout featuregate.Feature = "EnableAggregatedDiscoveryTimeout"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -589,8 +582,6 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
|||||||
apiextensionsfeatures.CustomResourcePublishOpenAPI: {Default: true, PreRelease: featuregate.GA, LockToDefault: true},
|
apiextensionsfeatures.CustomResourcePublishOpenAPI: {Default: true, PreRelease: featuregate.GA, LockToDefault: true},
|
||||||
apiextensionsfeatures.CustomResourceDefaulting: {Default: true, PreRelease: featuregate.Beta},
|
apiextensionsfeatures.CustomResourceDefaulting: {Default: true, PreRelease: featuregate.Beta},
|
||||||
|
|
||||||
EnableAggregatedDiscoveryTimeout: {Default: true, PreRelease: featuregate.Deprecated},
|
|
||||||
|
|
||||||
// features that enable backwards compatibility but are scheduled to be removed
|
// features that enable backwards compatibility but are scheduled to be removed
|
||||||
// ...
|
// ...
|
||||||
HPAScaleToZero: {Default: false, PreRelease: featuregate.Alpha},
|
HPAScaleToZero: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
@ -71,8 +71,6 @@ type ExtraConfig struct {
|
|||||||
|
|
||||||
// Mechanism by which the Aggregator will resolve services. Required.
|
// Mechanism by which the Aggregator will resolve services. Required.
|
||||||
ServiceResolver ServiceResolver
|
ServiceResolver ServiceResolver
|
||||||
|
|
||||||
EnableAggregatedDiscoveryTimeout bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config represents the configuration needed to create an APIAggregator.
|
// Config represents the configuration needed to create an APIAggregator.
|
||||||
@ -134,8 +132,6 @@ type APIAggregator struct {
|
|||||||
|
|
||||||
// openAPIAggregationController downloads and merges OpenAPI specs.
|
// openAPIAggregationController downloads and merges OpenAPI specs.
|
||||||
openAPIAggregationController *openapicontroller.AggregationController
|
openAPIAggregationController *openapicontroller.AggregationController
|
||||||
|
|
||||||
enableAggregatedDiscoveryTimeout bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.
|
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.
|
||||||
@ -176,18 +172,17 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
|
|||||||
)
|
)
|
||||||
|
|
||||||
s := &APIAggregator{
|
s := &APIAggregator{
|
||||||
GenericAPIServer: genericServer,
|
GenericAPIServer: genericServer,
|
||||||
delegateHandler: delegationTarget.UnprotectedHandler(),
|
delegateHandler: delegationTarget.UnprotectedHandler(),
|
||||||
proxyClientCert: c.ExtraConfig.ProxyClientCert,
|
proxyClientCert: c.ExtraConfig.ProxyClientCert,
|
||||||
proxyClientKey: c.ExtraConfig.ProxyClientKey,
|
proxyClientKey: c.ExtraConfig.ProxyClientKey,
|
||||||
proxyTransport: c.ExtraConfig.ProxyTransport,
|
proxyTransport: c.ExtraConfig.ProxyTransport,
|
||||||
proxyHandlers: map[string]*proxyHandler{},
|
proxyHandlers: map[string]*proxyHandler{},
|
||||||
handledGroups: sets.String{},
|
handledGroups: sets.String{},
|
||||||
lister: informerFactory.Apiregistration().V1().APIServices().Lister(),
|
lister: informerFactory.Apiregistration().V1().APIServices().Lister(),
|
||||||
APIRegistrationInformers: informerFactory,
|
APIRegistrationInformers: informerFactory,
|
||||||
serviceResolver: c.ExtraConfig.ServiceResolver,
|
serviceResolver: c.ExtraConfig.ServiceResolver,
|
||||||
openAPIConfig: openAPIConfig,
|
openAPIConfig: openAPIConfig,
|
||||||
enableAggregatedDiscoveryTimeout: c.ExtraConfig.EnableAggregatedDiscoveryTimeout,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apiGroupInfo := apiservicerest.NewRESTStorage(c.GenericConfig.MergedResourceConfig, c.GenericConfig.RESTOptionsGetter)
|
apiGroupInfo := apiservicerest.NewRESTStorage(c.GenericConfig.MergedResourceConfig, c.GenericConfig.RESTOptionsGetter)
|
||||||
@ -291,12 +286,11 @@ func (s *APIAggregator) AddAPIService(apiService *v1.APIService) error {
|
|||||||
|
|
||||||
// register the proxy handler
|
// register the proxy handler
|
||||||
proxyHandler := &proxyHandler{
|
proxyHandler := &proxyHandler{
|
||||||
localDelegate: s.delegateHandler,
|
localDelegate: s.delegateHandler,
|
||||||
proxyClientCert: s.proxyClientCert,
|
proxyClientCert: s.proxyClientCert,
|
||||||
proxyClientKey: s.proxyClientKey,
|
proxyClientKey: s.proxyClientKey,
|
||||||
proxyTransport: s.proxyTransport,
|
proxyTransport: s.proxyTransport,
|
||||||
serviceResolver: s.serviceResolver,
|
serviceResolver: s.serviceResolver,
|
||||||
enableAggregatedDiscoveryTimeout: s.enableAggregatedDiscoveryTimeout,
|
|
||||||
}
|
}
|
||||||
proxyHandler.updateAPIService(apiService)
|
proxyHandler.updateAPIService(apiService)
|
||||||
if s.openAPIAggregationController != nil {
|
if s.openAPIAggregationController != nil {
|
||||||
|
@ -63,8 +63,6 @@ type proxyHandler struct {
|
|||||||
serviceResolver ServiceResolver
|
serviceResolver ServiceResolver
|
||||||
|
|
||||||
handlingInfo atomic.Value
|
handlingInfo atomic.Value
|
||||||
|
|
||||||
enableAggregatedDiscoveryTimeout bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type proxyHandlingInfo struct {
|
type proxyHandlingInfo struct {
|
||||||
@ -148,7 +146,7 @@ func (r *proxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
location.Path = req.URL.Path
|
location.Path = req.URL.Path
|
||||||
location.RawQuery = req.URL.Query().Encode()
|
location.RawQuery = req.URL.Query().Encode()
|
||||||
|
|
||||||
newReq, cancelFn := newRequestForProxy(location, req, r.enableAggregatedDiscoveryTimeout)
|
newReq, cancelFn := newRequestForProxy(location, req)
|
||||||
defer cancelFn()
|
defer cancelFn()
|
||||||
|
|
||||||
if handlingInfo.proxyRoundTripper == nil {
|
if handlingInfo.proxyRoundTripper == nil {
|
||||||
@ -177,14 +175,14 @@ func (r *proxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newRequestForProxy returns a shallow copy of the original request with a context that may include a timeout for discovery requests
|
// newRequestForProxy returns a shallow copy of the original request with a context that may include a timeout for discovery requests
|
||||||
func newRequestForProxy(location *url.URL, req *http.Request, enableAggregatedDiscoveryTimeout bool) (*http.Request, context.CancelFunc) {
|
func newRequestForProxy(location *url.URL, req *http.Request) (*http.Request, context.CancelFunc) {
|
||||||
newCtx := req.Context()
|
newCtx := req.Context()
|
||||||
cancelFn := func() {}
|
cancelFn := func() {}
|
||||||
|
|
||||||
if requestInfo, ok := genericapirequest.RequestInfoFrom(req.Context()); ok {
|
if requestInfo, ok := genericapirequest.RequestInfoFrom(req.Context()); ok {
|
||||||
// trim leading and trailing slashes. Then "/apis/group/version" requests are for discovery, so if we have exactly three
|
// trim leading and trailing slashes. Then "/apis/group/version" requests are for discovery, so if we have exactly three
|
||||||
// segments that we are going to proxy, we have a discovery request.
|
// segments that we are going to proxy, we have a discovery request.
|
||||||
if enableAggregatedDiscoveryTimeout && !requestInfo.IsResourceRequest && len(strings.Split(strings.Trim(requestInfo.Path, "/"), "/")) == 3 {
|
if !requestInfo.IsResourceRequest && len(strings.Split(strings.Trim(requestInfo.Path, "/"), "/")) == 3 {
|
||||||
// discovery requests are used by kubectl and others to determine which resources a server has. This is a cheap call that
|
// discovery requests are used by kubectl and others to determine which resources a server has. This is a cheap call that
|
||||||
// should be fast for every aggregated apiserver. Latency for aggregation is expected to be low (as for all extensions)
|
// should be fast for every aggregated apiserver. Latency for aggregation is expected to be low (as for all extensions)
|
||||||
// so forcing a short timeout here helps responsiveness of all clients.
|
// so forcing a short timeout here helps responsiveness of all clients.
|
||||||
|
@ -541,7 +541,7 @@ func TestGetContextForNewRequest(t *testing.T) {
|
|||||||
location.Path = req.URL.Path
|
location.Path = req.URL.Path
|
||||||
|
|
||||||
nestedReq := req.WithContext(genericapirequest.WithRequestInfo(req.Context(), &genericapirequest.RequestInfo{Path: req.URL.Path}))
|
nestedReq := req.WithContext(genericapirequest.WithRequestInfo(req.Context(), &genericapirequest.RequestInfo{Path: req.URL.Path}))
|
||||||
newReq, cancelFn := newRequestForProxy(location, nestedReq, true)
|
newReq, cancelFn := newRequestForProxy(location, nestedReq)
|
||||||
defer cancelFn()
|
defer cancelFn()
|
||||||
|
|
||||||
theproxy := proxy.NewUpgradeAwareHandler(location, server.Client().Transport, true, false, &responder{w: w})
|
theproxy := proxy.NewUpgradeAwareHandler(location, server.Client().Transport, true, false, &responder{w: w})
|
||||||
|
Loading…
Reference in New Issue
Block a user