11167: Merge branch 'master' into 11167-wb-remove-arvget
authorLucas Di Pentima <lucas@curoverse.com>
Mon, 7 Aug 2017 21:55:59 +0000 (18:55 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Mon, 7 Aug 2017 21:57:11 +0000 (18:57 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@curoverse.com>

1  2 
apps/workbench/config/application.default.yml
services/keep-web/handler.go

index 2557b47ee91fd9859f63dcf9e46a13df467331ae,9f6c1ed338042764c3f38d506753caab7682350e..da20573abb859b96a5202983ab9e77e1703ac25f
@@@ -99,9 -99,6 +99,9 @@@ test
    profiling_enabled: true
    secret_token: <%= rand(2**256).to_s(36) %>
    secret_key_base: <%= rand(2**256).to_s(36) %>
 +  # This setting is to allow workbench start when running tests, it should be
 +  # set to a correct value when testing relevant features.
 +  keep_web_url: http://example.com/c=%{uuid_or_pdh}
  
    # When you run the Workbench's integration tests, it starts the API
    # server as a dependency.  These settings should match the API
@@@ -246,8 -243,8 +246,8 @@@ common
    shell_in_a_box_url: false
  
    # Format of preview links. If false, use keep_web_download_url
 -  # instead, and disable inline preview. If both are false, use
 -  # Workbench's built-in file download/preview mechanism.
 +  # instead, and disable inline preview.
 +  # If both are false, Workbench won't start, this is a mandatory configuration.
    #
    # Examples:
    # keep_web_url: https://%{uuid_or_pdh}.collections.uuid_prefix.arvadosapi.com
  
    # Token to be included in all healthcheck requests. Disabled by default.
    # Workbench expects request header of the format "Authorization: Bearer xxx"
-   management_token: false
+   ManagementToken: false
index 23c38ca52351427ddc749dafe3c004edf4297d8e,16df210fe83cc12096549f5609fafeecdcc09340..67d46f6716b2ce22b09cb6b1204b08fdb3c3dd96
@@@ -21,14 -21,16 +21,16 @@@ import 
        "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "git.curoverse.com/arvados.git/sdk/go/auth"
+       "git.curoverse.com/arvados.git/sdk/go/health"
        "git.curoverse.com/arvados.git/sdk/go/httpserver"
        "git.curoverse.com/arvados.git/sdk/go/keepclient"
  )
  
  type handler struct {
-       Config     *Config
-       clientPool *arvadosclient.ClientPool
-       setupOnce  sync.Once
+       Config        *Config
+       clientPool    *arvadosclient.ClientPool
+       setupOnce     sync.Once
+       healthHandler http.Handler
  }
  
  // parseCollectionIDFromDNSName returns a UUID or PDH if s begins with
@@@ -70,7 -72,13 +72,13 @@@ func parseCollectionIDFromURL(s string
  
  func (h *handler) setup() {
        h.clientPool = arvadosclient.MakeClientPool()
        keepclient.RefreshServiceDiscoveryOnSIGHUP()
+       h.healthHandler = &health.Handler{
+               Token:  h.Config.ManagementToken,
+               Prefix: "/_health/",
+       }
  }
  
  func (h *handler) serveStatus(w http.ResponseWriter, r *http.Request) {
@@@ -110,6 -118,11 +118,11 @@@ func (h *handler) ServeHTTP(wOrig http.
                httpserver.Log(remoteAddr, statusCode, statusText, w.WroteBodyBytes(), r.Method, r.Host, r.URL.Path, r.URL.RawQuery)
        }()
  
+       if strings.HasPrefix(r.URL.Path, "/_health/") && r.Method == "GET" {
+               h.healthHandler.ServeHTTP(w, r)
+               return
+       }
        if r.Method == "OPTIONS" {
                method := r.Header.Get("Access-Control-Request-Method")
                if method != "GET" && method != "POST" {
                // SSL certificates. See
                // http://www.w3.org/TR/cors/#user-credentials).
                w.Header().Set("Access-Control-Allow-Origin", "*")
 +              w.Header().Set("Access-Control-Expose-Headers", "Content-Range")
        }
  
        arv := h.clientPool.Get()