16133: Avoid cycle when searching federation for PDH.
authorTom Clegg <tom@tomclegg.ca>
Thu, 6 Feb 2020 15:19:04 +0000 (10:19 -0500)
committerTom Clegg <tom@tomclegg.ca>
Thu, 6 Feb 2020 16:02:51 +0000 (11:02 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/controller/federation/conn.go
sdk/go/arvados/api.go

index 1b1ffef24cf3a1c6bb2245f3d4c9cb258118e620..0416549ca4d2390c78e04e57798d7010b5911375 100644 (file)
@@ -214,6 +214,8 @@ func (conn *Conn) Login(ctx context.Context, options arvados.LoginOptions) (arva
 }
 
 func (conn *Conn) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
+       downstream := options.ForwardedFor
+       options.ForwardedFor = conn.cluster.ClusterID + "-" + downstream
        if len(options.UUID) == 27 {
                // UUID is really a UUID
                c, err := conn.chooseBackend(options.UUID).CollectionGet(ctx, options)
@@ -225,6 +227,9 @@ func (conn *Conn) CollectionGet(ctx context.Context, options arvados.GetOptions)
                // UUID is a PDH
                first := make(chan arvados.Collection, 1)
                err := conn.tryLocalThenRemotes(ctx, func(ctx context.Context, remoteID string, be backend) error {
+                       if remoteID != "" && strings.Contains(downstream, remoteID) {
+                               return notFoundError{}
+                       }
                        c, err := be.CollectionGet(ctx, options)
                        if err != nil {
                                return err
index 6e115a15f6f6232c5e7add504e04aff09309e759..aa670c53921ff0a4be5f6765347b06ede278d0d1 100644 (file)
@@ -62,6 +62,7 @@ type GetOptions struct {
        UUID         string   `json:"uuid"`
        Select       []string `json:"select"`
        IncludeTrash bool     `json:"include_trash"`
+       ForwardedFor string   `json:"forwarded_for"`
 }
 
 type UntrashOptions struct {