_ "net/http/pprof"
"net/url"
"os"
+ "regexp"
"strings"
"time"
Priority: c.requestPriority,
Registry: reg,
Queue: func(req *http.Request) *httpserver.RequestQueue {
- if strings.HasPrefix(req.URL.Path, "/arvados/v1/connect/") {
+ if req.Method == http.MethodPost && reTunnelPath.MatchString(req.URL.Path) {
return rqTunnel
} else {
return rqAPI
}
}
+// reTunnelPath matches paths of API endpoints that go in the "tunnel"
+// queue.
+var reTunnelPath = regexp.MustCompile(func() string {
+ rePathVar := regexp.MustCompile(`{.*?}`)
+ out := ""
+ for _, endpoint := range []arvados.APIEndpoint{
+ arvados.EndpointContainerGatewayTunnel,
+ arvados.EndpointContainerGatewayTunnelCompat,
+ arvados.EndpointContainerSSH,
+ arvados.EndpointContainerSSHCompat,
+ } {
+ if out != "" {
+ out += "|"
+ }
+ out += `\Q/` + rePathVar.ReplaceAllString(endpoint.Path, `\E[^/]*\Q`) + `\E`
+ }
+ return "^(" + out + ")$"
+}())
+
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"):