diff --git a/pkg/endpoints/request/requestcontext.go b/pkg/endpoints/request/requestcontext.go index 32fa9215f..3dc771baf 100644 --- a/pkg/endpoints/request/requestcontext.go +++ b/pkg/endpoints/request/requestcontext.go @@ -24,6 +24,9 @@ import ( "github.com/golang/glog" ) +// LongRunningRequestCheck is a predicate which is true for long-running http requests. +type LongRunningRequestCheck func(r *http.Request, requestInfo *RequestInfo) bool + // RequestContextMapper keeps track of the context associated with a particular request type RequestContextMapper interface { // Get returns the context associated with the given request (if any), and true if the request has an associated context, and false if it does not. diff --git a/pkg/server/config.go b/pkg/server/config.go index e949a93e9..bb6710f05 100644 --- a/pkg/server/config.go +++ b/pkg/server/config.go @@ -150,7 +150,7 @@ type Config struct { // request has to wait. MaxMutatingRequestsInFlight int // Predicate which is true for paths of long-running http requests - LongRunningFunc genericfilters.LongRunningRequestCheck + LongRunningFunc apirequest.LongRunningRequestCheck //=========================================================================== // values below here are targets for removal diff --git a/pkg/server/filters/longrunning.go b/pkg/server/filters/longrunning.go index 4ea58625b..21c4562aa 100644 --- a/pkg/server/filters/longrunning.go +++ b/pkg/server/filters/longrunning.go @@ -23,11 +23,8 @@ import ( apirequest "k8s.io/apiserver/pkg/endpoints/request" ) -// LongRunningRequestCheck is a predicate which is true for long-running http requests. -type LongRunningRequestCheck func(r *http.Request, requestInfo *apirequest.RequestInfo) bool - // BasicLongRunningRequestCheck returns true if the given request has one of the specified verbs or one of the specified subresources -func BasicLongRunningRequestCheck(longRunningVerbs, longRunningSubresources sets.String) LongRunningRequestCheck { +func BasicLongRunningRequestCheck(longRunningVerbs, longRunningSubresources sets.String) apirequest.LongRunningRequestCheck { return func(r *http.Request, requestInfo *apirequest.RequestInfo) bool { if longRunningVerbs.Has(requestInfo.Verb) { return true diff --git a/pkg/server/filters/maxinflight.go b/pkg/server/filters/maxinflight.go index c480d7b6e..0100e05f8 100644 --- a/pkg/server/filters/maxinflight.go +++ b/pkg/server/filters/maxinflight.go @@ -47,7 +47,7 @@ func WithMaxInFlightLimit( nonMutatingLimit int, mutatingLimit int, requestContextMapper genericapirequest.RequestContextMapper, - longRunningRequestCheck LongRunningRequestCheck, + longRunningRequestCheck apirequest.LongRunningRequestCheck, ) http.Handler { if nonMutatingLimit == 0 && mutatingLimit == 0 { return handler diff --git a/pkg/server/filters/timeout.go b/pkg/server/filters/timeout.go index ed2de1a99..19894b470 100644 --- a/pkg/server/filters/timeout.go +++ b/pkg/server/filters/timeout.go @@ -35,7 +35,7 @@ const globalTimeout = time.Minute var errConnKilled = fmt.Errorf("kill connection/stream") // WithTimeoutForNonLongRunningRequests times out non-long-running requests after the time given by globalTimeout. -func WithTimeoutForNonLongRunningRequests(handler http.Handler, requestContextMapper apirequest.RequestContextMapper, longRunning LongRunningRequestCheck) http.Handler { +func WithTimeoutForNonLongRunningRequests(handler http.Handler, requestContextMapper apirequest.RequestContextMapper, longRunning apirequest.LongRunningRequestCheck) http.Handler { if longRunning == nil { return handler }