16306: Merge branch 'master'
[arvados.git] / lib / controller / fed_collections.go
index 07daf2f90ef28b3199e856c93134aa5b6975fab3..a0a123129fdacdae34bf8b216d3e6b766a6f5889 100644 (file)
@@ -17,9 +17,9 @@ import (
        "strings"
        "sync"
 
-       "git.curoverse.com/arvados.git/sdk/go/arvados"
-       "git.curoverse.com/arvados.git/sdk/go/httpserver"
-       "git.curoverse.com/arvados.git/sdk/go/keepclient"
+       "git.arvados.org/arvados.git/sdk/go/arvados"
+       "git.arvados.org/arvados.git/sdk/go/httpserver"
+       "git.arvados.org/arvados.git/sdk/go/keepclient"
 )
 
 func rewriteSignatures(clusterID string, expectHash string,
@@ -157,7 +157,7 @@ type searchRemoteClusterForPDH struct {
 func fetchRemoteCollectionByUUID(
        h *genericFederatedRequestHandler,
        effectiveMethod string,
-       clusterId *string,
+       clusterID *string,
        uuid string,
        remainder string,
        w http.ResponseWriter,
@@ -170,11 +170,11 @@ func fetchRemoteCollectionByUUID(
 
        if uuid != "" {
                // Collection UUID GET request
-               *clusterId = uuid[0:5]
-               if *clusterId != "" && *clusterId != h.handler.Cluster.ClusterID {
+               *clusterID = uuid[0:5]
+               if *clusterID != "" && *clusterID != h.handler.Cluster.ClusterID {
                        // request for remote collection by uuid
-                       resp, err := h.handler.remoteClusterRequest(*clusterId, req)
-                       newResponse, err := rewriteSignatures(*clusterId, "", resp, err)
+                       resp, err := h.handler.remoteClusterRequest(*clusterID, req)
+                       newResponse, err := rewriteSignatures(*clusterID, "", resp, err)
                        h.handler.proxy.ForwardResponse(w, newResponse, err)
                        return true
                }
@@ -186,7 +186,7 @@ func fetchRemoteCollectionByUUID(
 func fetchRemoteCollectionByPDH(
        h *genericFederatedRequestHandler,
        effectiveMethod string,
-       clusterId *string,
+       clusterID *string,
        uuid string,
        remainder string,
        w http.ResponseWriter,
@@ -232,6 +232,10 @@ func fetchRemoteCollectionByPDH(
                        // No need to query local cluster again
                        continue
                }
+               if remoteID == "*" {
+                       // This isn't a real remote cluster: it just sets defaults for unlisted remotes.
+                       continue
+               }
 
                wg.Add(1)
                go func(remote string) {
@@ -293,10 +297,8 @@ func fetchRemoteCollectionByPDH(
                        var errors []string
                        for len(errorChan) > 0 {
                                err := <-errorChan
-                               if httperr, ok := err.(HTTPError); ok {
-                                       if httperr.Code != http.StatusNotFound {
-                                               errorCode = http.StatusBadGateway
-                                       }
+                               if httperr, ok := err.(HTTPError); !ok || httperr.Code != http.StatusNotFound {
+                                       errorCode = http.StatusBadGateway
                                }
                                errors = append(errors, err.Error())
                        }