21834: Restore timestamps in stdout.txt, stderr.txt.
[arvados.git] / lib / service / cmd.go
index e40b47acbbb6d4bb1b96a9de1bf2d625e28b2430..9ed0acfb8f7151e805c7269dceacb696f425c07b 100644 (file)
@@ -16,6 +16,7 @@ import (
        _ "net/http/pprof"
        "net/url"
        "os"
+       "regexp"
        "strings"
        "time"
 
@@ -79,9 +80,9 @@ func (c *command) RunCommand(prog string, args []string, stdin io.Reader, stdout
        loader := config.NewLoader(stdin, log)
        loader.SetupFlags(flags)
 
-       // prog is [keepstore, keep-web, git-httpd, ...]  but the
+       // prog is [keepstore, keep-web, ...]  but the
        // legacy config flags are [-legacy-keepstore-config,
-       // -legacy-keepweb-config, -legacy-git-httpd-config, ...]
+       // -legacy-keepweb-config, ...]
        legacyFlag := "-legacy-" + strings.Replace(prog, "keep-", "keep", 1) + "-config"
        args = loader.MungeLegacyConfigArgs(log, args, legacyFlag)
 
@@ -297,7 +298,7 @@ func (c *command) requestLimiter(handler http.Handler, cluster *arvados.Cluster,
                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
@@ -306,6 +307,25 @@ func (c *command) requestLimiter(handler http.Handler, cluster *arvados.Cluster,
        }
 }
 
+// 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"):