"flag"
"fmt"
"io"
- "math"
"net"
"net/http"
"net/http/httptest"
// Return 503 immediately instead of queueing. We want
// to send feedback to dispatchcloud ASAP to stop
// bringing up new containers.
- return math.MinInt64
+ return httpserver.IneligibleForQueuePriority
case req.Method == http.MethodPost && strings.HasPrefix(req.URL.Path, "/arvados/v1/logs"):
// "Create log entry" is the most harmless kind of
// request to drop.
"github.com/sirupsen/logrus"
)
+const IneligibleForQueuePriority = math.MinInt64
+
// RequestLimiter wraps http.Handler, limiting the number of
// concurrent requests being handled by the wrapped Handler. Requests
// that arrive when the handler is already at the specified
ent.ready <- true
return ent
}
- if priority == math.MinInt64 {
+ if priority == IneligibleForQueuePriority {
// Priority func is telling us to return 503
// immediately instead of queueing, regardless of
// queue size, if we can't handle the request
import (
"fmt"
- "math"
"net/http"
"net/http/httptest"
"strconv"
<-h.inHandler
}
- c.Logf("starting %d priority=MinInt64 requests (should respond 503 immediately)", rl.MaxQueue)
+ c.Logf("starting %d priority=IneligibleForQueuePriority requests (should respond 503 immediately)", rl.MaxQueue)
var wgX sync.WaitGroup
for i := 0; i < rl.MaxQueue; i++ {
wgX.Add(1)
go func() {
defer wgX.Done()
resp := httptest.NewRecorder()
- rl.ServeHTTP(resp, &http.Request{Header: http.Header{"Priority": {fmt.Sprintf("%d", math.MinInt64)}}})
+ rl.ServeHTTP(resp, &http.Request{Header: http.Header{"Priority": {fmt.Sprintf("%d", IneligibleForQueuePriority)}}})
c.Check(resp.Code, check.Equals, http.StatusServiceUnavailable)
}()
}