"flag"
"fmt"
"io"
+ "math"
"net"
"net/http"
"net/http/httptest"
Handler: handler,
MaxConcurrent: cluster.API.MaxConcurrentRequests,
MaxQueue: cluster.API.MaxQueuedRequests,
+ Priority: c.requestPriority,
Registry: reg}))))))
srv := &httpserver.Server{
Server: http.Server{
}
}
+func (c *command) requestPriority(req *http.Request, queued time.Time) int64 {
+ switch {
+ case req.Method == http.MethodPost && strings.HasPrefix(req.URL.Path, "/arvados/v1/containers/") && strings.HasSuffix(req.URL.Path, "/lock"):
+ // Return 503 immediately instead of queueing. We want
+ // to send feedback to dispatchcloud ASAP to stop
+ // bringing up new containers.
+ return math.MinInt64
+ 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.
+ return 0
+ case req.Header.Get("Origin") != "":
+ // Handle interactive requests first.
+ return 2
+ default:
+ return 1
+ }
+}
+
// If an incoming request's target vhost has an embedded collection
// UUID or PDH, handle it with hTrue, otherwise handle it with
// hFalse.