@@ -181,13 +181,15 @@ func newRequestForProxy(location *url.URL, req *http.Request, enableAggregatedDi
181
181
newCtx := req .Context ()
182
182
cancelFn := func () {}
183
183
184
- // trim leading and trailing slashes. Then "/apis/group/version" requests are for discovery, so if we have exactly three
185
- // segments that we are going to proxy, we have a discovery request.
186
- if enableAggregatedDiscoveryTimeout && len (strings .Split (strings .Trim (req .URL .Path , "/" ), "/" )) == 3 {
187
- // discovery requests are used by kubectl and others to determine which resources a server has. This is a cheap call that
188
- // should be fast for every aggregated apiserver. Latency for aggregation is expected to be low (as for all extensions)
189
- // so forcing a short timeout here helps responsiveness of all clients.
190
- newCtx , cancelFn = context .WithTimeout (newCtx , aggregatedDiscoveryTimeout )
184
+ if requestInfo , ok := genericapirequest .RequestInfoFrom (req .Context ()); ok {
185
+ // trim leading and trailing slashes. Then "/apis/group/version" requests are for discovery, so if we have exactly three
186
+ // segments that we are going to proxy, we have a discovery request.
187
+ if enableAggregatedDiscoveryTimeout && ! requestInfo .IsResourceRequest && len (strings .Split (strings .Trim (requestInfo .Path , "/" ), "/" )) == 3 {
188
+ // discovery requests are used by kubectl and others to determine which resources a server has. This is a cheap call that
189
+ // should be fast for every aggregated apiserver. Latency for aggregation is expected to be low (as for all extensions)
190
+ // so forcing a short timeout here helps responsiveness of all clients.
191
+ newCtx , cancelFn = context .WithTimeout (newCtx , aggregatedDiscoveryTimeout )
192
+ }
191
193
}
192
194
193
195
// WithContext creates a shallow clone of the request with the same context.
0 commit comments