@@ -20,6 +20,8 @@ import (
20
20
"context"
21
21
"net/http"
22
22
"net/url"
23
+ "os"
24
+ "strconv"
23
25
"strings"
24
26
"sync/atomic"
25
27
"time"
@@ -29,6 +31,7 @@ import (
29
31
"k8s.io/apimachinery/pkg/util/httpstream/spdy"
30
32
utilnet "k8s.io/apimachinery/pkg/util/net"
31
33
"k8s.io/apimachinery/pkg/util/proxy"
34
+ utilruntime "k8s.io/apimachinery/pkg/util/runtime"
32
35
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
33
36
endpointmetrics "k8s.io/apiserver/pkg/endpoints/metrics"
34
37
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
@@ -47,6 +50,19 @@ const (
47
50
aggregatedDiscoveryTimeout = 5 * time .Second
48
51
)
49
52
53
+ var (
54
+ // TODO this should be unconditionally true once we remove the env var override
55
+ enableAggregatedDiscoveryTimeout = true
56
+ )
57
+
58
+ func init () {
59
+ disableAggregatedDiscoveryTimeout , err := strconv .ParseBool (os .Getenv ("DEPRECATED_DISABLE_AGGREGATOR_DISCOVERY_TIMEOUT" ))
60
+ if err != nil {
61
+ utilruntime .HandleError (err )
62
+ }
63
+ enableAggregatedDiscoveryTimeout = ! disableAggregatedDiscoveryTimeout
64
+ }
65
+
50
66
// proxyHandler provides a http.Handler which will proxy traffic to locations
51
67
// specified by items implementing Redirector.
52
68
type proxyHandler struct {
@@ -185,7 +201,7 @@ func newRequestForProxy(location *url.URL, req *http.Request) (*http.Request, co
185
201
186
202
// trim leading and trailing slashes. Then "/apis/group/version" requests are for discovery, so if we have exactly three
187
203
// segments that we are going to proxy, we have a discovery request.
188
- } else if len (strings .Split (strings .Trim (req .URL .Path , "/" ), "/" )) == 3 {
204
+ } else if enableAggregatedDiscoveryTimeout && len (strings .Split (strings .Trim (req .URL .Path , "/" ), "/" )) == 3 {
189
205
// discovery requests are used by kubectl and others to determine which resources a server has. This is a cheap call that
190
206
// should be fast for every aggregated apiserver. Latency for aggregation is expected to be low (as for all extensions)
191
207
// so forcing a short timeout here helps responsiveness of all clients.
0 commit comments