Skip to content

Commit b1be794

Browse files
committed
fix(decomposedfs): tolerate a space root with an unset name attribute
ReadNode failed with an internal error when a space root had no user.oc.name attribute, which happens for a half-deleted user space (its node lingers while the name attribute is already gone). Reading the name with XattrString returned the ENODATA error and the whole ReadNode aborted with gRPC code 15. The search service's tree walk stats every space root through this path, so one such node aborted the entire space index and logged "error while indexing a space" on every run; any other ReadNode caller hit the same hard failure. Swallow the unset-name case the same way the owner lookup just above already swallows a missing attribute: match metadata.IsAttrUnset and keep the empty name instead of failing the read. Any other read error keeps its existing behaviour, so a genuine read failure is not hidden. Related: opencloud-eu/opencloud#1878
1 parent 3d1ff52 commit b1be794

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

pkg/storage/pkg/decomposedfs/node/node.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,10 @@ func readNode(ctx context.Context, lu PathLookup, spaceID, nodeID, internalPath
423423

424424
// lookup name in extended attributes
425425
spaceRoot.Name, err = spaceRoot.XattrString(ctx, prefixes.NameAttr)
426-
if err != nil {
426+
switch {
427+
case metadata.IsAttrUnset(err):
428+
// swallow an unset name, the node keeps its empty name
429+
case err != nil:
427430
return nil, err
428431
}
429432
}

pkg/storage/pkg/decomposedfs/node/node_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
. "github.com/onsi/gomega"
3030
ocsconv "github.com/opencloud-eu/reva/v2/pkg/conversions"
3131
ctxpkg "github.com/opencloud-eu/reva/v2/pkg/ctx"
32+
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/metadata/prefixes"
3233
"github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/node"
3334
helpers "github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/testhelpers"
3435
"github.com/opencloud-eu/reva/v2/pkg/storage/utils/grants"
@@ -81,6 +82,21 @@ var _ = Describe("Node", func() {
8182
Expect(err).ToNot(HaveOccurred())
8283
Expect(n.BlobID).To(Equal("file1-blobid"))
8384
})
85+
86+
It("treats a space root with an unset name attribute as nameless instead of failing", func() {
87+
spaceRoot, err := env.Lookup.NodeFromSpaceID(env.Ctx, env.SpaceRootRes.SpaceId)
88+
Expect(err).ToNot(HaveOccurred())
89+
90+
// simulate a half-deleted space root whose name attribute is gone
91+
err = spaceRoot.RemoveXattr(env.Ctx, prefixes.NameAttr, true)
92+
Expect(err).ToNot(HaveOccurred())
93+
94+
n, err := node.ReadNode(env.Ctx, env.Lookup, spaceRoot.SpaceID, spaceRoot.ID, "", false, nil, false)
95+
Expect(err).ToNot(HaveOccurred())
96+
Expect(n).ToNot(BeNil())
97+
Expect(n.Exists).To(BeTrue())
98+
Expect(n.Name).To(Equal(""))
99+
})
84100
})
85101

86102
Describe("WriteMetadata", func() {

0 commit comments

Comments
 (0)