[arvados] created: 2.1.0-2840-g64b0ef391

git repository hosting git at public.arvados.org
Wed Aug 10 18:52:39 UTC 2022


        at  64b0ef39156adace0a5c02e2b54441cdecd94ce1 (commit)


commit 64b0ef39156adace0a5c02e2b54441cdecd94ce1
Author: Tom Clegg <tom at curii.com>
Date:   Wed Aug 10 14:51:01 2022 -0400

    19368: Use Sys() instead of .arvados# file to get collection ID.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/fs_collection.go b/sdk/go/arvados/fs_collection.go
index eb3e974ed..26012e240 100644
--- a/sdk/go/arvados/fs_collection.go
+++ b/sdk/go/arvados/fs_collection.go
@@ -954,17 +954,6 @@ func (dn *dirnode) Child(name string, replace func(inode) (inode, error)) (inode
 		gn.SetParent(dn, name)
 		return gn, nil
 	}
-	if dn == dn.fs.rootnode() && name == ".arvados#collection_id" {
-		gn := &getternode{Getter: func() ([]byte, error) {
-			data, err := json.Marshal(Collection{UUID: dn.fs.uuid})
-			if err == nil {
-				data = append(data, '\n')
-			}
-			return data, err
-		}}
-		gn.SetParent(dn, name)
-		return gn, nil
-	}
 	return dn.treenode.Child(name, replace)
 }
 
diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go
index a6187043b..05852399a 100644
--- a/services/keep-web/handler.go
+++ b/services/keep-web/handler.go
@@ -909,17 +909,21 @@ func (h *handler) logUploadOrDownload(
 		collection, filepath = h.determineCollection(fs, filepath)
 	}
 	if collection != nil {
-		log = log.WithField("collection_uuid", collection.UUID).
-			WithField("collection_file_path", filepath)
-		props["collection_uuid"] = collection.UUID
+		log = log.WithField("collection_file_path", filepath)
 		props["collection_file_path"] = filepath
-		// h.determineCollection populates the collection_uuid prop with the PDH, if
-		// this collection is being accessed via PDH. In that case, blank the
-		// collection_uuid field so that consumers of the log entries can rely on it
-		// being a UUID, or blank. The PDH remains available via the
-		// portable_data_hash property.
-		if props["collection_uuid"] == collection.PortableDataHash {
-			props["collection_uuid"] = ""
+		// h.determineCollection populates the collection_uuid
+		// prop with the PDH, if this collection is being
+		// accessed via PDH. For logging, we use a different
+		// field depending on whether it's a UUID or PDH.
+		if len(collection.UUID) > 32 {
+			log = log.WithField("portable_data_hash", collection.UUID)
+			props["portable_data_hash"] = collection.UUID
+		} else {
+			log = log.WithField("collection_uuid", collection.UUID)
+			props["collection_uuid"] = collection.UUID
+			if collection.PortableDataHash != "" {
+				props["portable_data_hash"] = collection.PortableDataHash
+			}
 		}
 	}
 	if r.Method == "PUT" || r.Method == "POST" {
@@ -958,29 +962,27 @@ func (h *handler) logUploadOrDownload(
 }
 
 func (h *handler) determineCollection(fs arvados.CustomFileSystem, path string) (*arvados.Collection, string) {
-	segments := strings.Split(path, "/")
-	var i int
-	for i = 0; i < len(segments); i++ {
-		dir := append([]string{}, segments[0:i]...)
-		dir = append(dir, ".arvados#collection_id")
-		f, err := fs.OpenFile(strings.Join(dir, "/"), os.O_RDONLY, 0)
-		if f != nil {
-			defer f.Close()
-		}
+	target := strings.TrimSuffix(path, "/")
+	for {
+		fi, err := fs.Stat(target)
 		if err != nil {
-			if !os.IsNotExist(err) {
+			return nil, ""
+		}
+		switch src := fi.Sys().(type) {
+		case *arvados.Collection:
+			return src, strings.TrimPrefix(path[len(target):], "/")
+		case *arvados.Group:
+			return nil, ""
+		default:
+			if _, ok := src.(error); ok {
 				return nil, ""
 			}
-			continue
 		}
-		// err is nil so we found it.
-		decoder := json.NewDecoder(f)
-		var collection arvados.Collection
-		err = decoder.Decode(&collection)
-		if err != nil {
+		// Try parent
+		cut := strings.LastIndexByte(target, '/')
+		if cut < 0 {
 			return nil, ""
 		}
-		return &collection, strings.Join(segments[i:], "/")
+		target = target[:cut]
 	}
-	return nil, ""
 }

commit b660e9b929f79fc567788ad7282d3ca564718c3c
Author: Tom Clegg <tom at curii.com>
Date:   Tue Aug 9 11:18:05 2022 -0400

    19368: Skip regenerating manifest during webdav/s3 logging.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/fs_collection.go b/sdk/go/arvados/fs_collection.go
index 26012e240..eb3e974ed 100644
--- a/sdk/go/arvados/fs_collection.go
+++ b/sdk/go/arvados/fs_collection.go
@@ -954,6 +954,17 @@ func (dn *dirnode) Child(name string, replace func(inode) (inode, error)) (inode
 		gn.SetParent(dn, name)
 		return gn, nil
 	}
+	if dn == dn.fs.rootnode() && name == ".arvados#collection_id" {
+		gn := &getternode{Getter: func() ([]byte, error) {
+			data, err := json.Marshal(Collection{UUID: dn.fs.uuid})
+			if err == nil {
+				data = append(data, '\n')
+			}
+			return data, err
+		}}
+		gn.SetParent(dn, name)
+		return gn, nil
+	}
 	return dn.treenode.Child(name, replace)
 }
 
diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go
index 1f1f50986..a6187043b 100644
--- a/services/keep-web/handler.go
+++ b/services/keep-web/handler.go
@@ -962,7 +962,7 @@ func (h *handler) determineCollection(fs arvados.CustomFileSystem, path string)
 	var i int
 	for i = 0; i < len(segments); i++ {
 		dir := append([]string{}, segments[0:i]...)
-		dir = append(dir, ".arvados#collection")
+		dir = append(dir, ".arvados#collection_id")
 		f, err := fs.OpenFile(strings.Join(dir, "/"), os.O_RDONLY, 0)
 		if f != nil {
 			defer f.Close()

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list