Skip to content

Commit

Permalink
Merge branch 'edge' into nodes-per-space
Browse files Browse the repository at this point in the history
  • Loading branch information
butonic committed Feb 14, 2022
2 parents cbc1bed + c7e6607 commit 752c692
Show file tree
Hide file tree
Showing 15 changed files with 643 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .drone.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The test runner source for API tests
CORE_COMMITID=a0fb3af23939f5573c7b0a54d68204b6c705ed81
CORE_COMMITID=3e0e77186b4f0236d13d5ad1bc1454f7a0873d77
CORE_BRANCH=master
5 changes: 5 additions & 0 deletions changelog/unreleased/change-space-attributes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Store space attributes in decomposedFS

We need to store more space attributes in the storage. This implements extended space attributes in the decomposedFS

https://github.com/cs3org/reva/pull/2527
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Use description during space creation

We can now use a space description during space creation. We also fixed a bug in the spaces roles. Co-owners are now maintainers.

https://github.com/cs3org/reva/pull/2524
5 changes: 5 additions & 0 deletions changelog/unreleased/decomposedfs-xattr-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Refactored the xattrs package in the decomposedfs

The xattrs package now uses the xattr.ENOATTR instead of os.ENODATA or os.ENOATTR to check attribute existence.

https://github.com/cs3org/reva/pull/2540
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestPermissions2Role(t *testing.T) {
table := map[Permissions]string{
PermissionRead: RoleViewer,
PermissionRead | PermissionWrite | PermissionCreate | PermissionDelete: RoleEditor,
PermissionAll: RoleCoowner,
PermissionAll: RoleManager,
PermissionWrite: RoleLegacy,
PermissionShare: RoleLegacy,
PermissionWrite | PermissionShare: RoleLegacy,
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocs/conversions/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func RoleFromOCSPermissions(p Permissions) *Role {
if p.Contain(PermissionRead) {
if p.Contain(PermissionWrite) && p.Contain(PermissionCreate) && p.Contain(PermissionDelete) {
if p.Contain(PermissionShare) {
return NewCoownerRole()
return NewManagerRole()
}
return NewEditorRole()
}
Expand Down
43 changes: 27 additions & 16 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string) (n *No
switch {
case err == nil:
n.ParentID = attr
case isAttrUnset(err):
case xattrs.IsAttrUnset(err):
return nil, errtypes.InternalError(err.Error())
case isNotFound(err):
case xattrs.IsNotExist(err):
return n, nil // swallow not found, the node defaults to exists = false
default:
return nil, errtypes.InternalError(err.Error())
Expand Down Expand Up @@ -219,7 +219,7 @@ func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string) (n *No

_, err = os.Stat(n.ParentInternalPath())
if err != nil {
if isNotFound(err) {
if os.IsNotExist(err) {
return nil, errtypes.NotFound(err.Error())
}
return nil, err
Expand Down Expand Up @@ -263,9 +263,15 @@ func (n *Node) Child(ctx context.Context, name string) (*Node, error) {
return nil, errors.Wrap(err, "decomposedfs: Wrap: readlink error")
}

c, err := ReadNode(ctx, n.lu, spaceID, filepath.Base(link))
if err != nil {
return nil, errors.Wrap(err, "could not read child node")
var c *Node
if strings.HasPrefix(link, "../") {
c, err = ReadNode(ctx, n.lu, filepath.Base(link))
if err != nil {
return nil, errors.Wrap(err, "could not read child node")
}
c.SpaceRoot = n.SpaceRoot
} else {
return nil, fmt.Errorf("decomposedfs: expected '../ prefix, got' %+v", link)
}
c.SpaceRoot = n.SpaceRoot
c.SpaceID = spaceID
Expand Down Expand Up @@ -335,7 +341,7 @@ func (n *Node) Owner() (*userpb.UserId, error) {
switch {
case err == nil:
owner.OpaqueId = attr
case isAttrUnset(err), isNotFound(err):
case xattrs.IsAttrUnset(err), xattrs.IsNotExist(err):
fallthrough
default:
return nil, err
Expand All @@ -346,7 +352,7 @@ func (n *Node) Owner() (*userpb.UserId, error) {
switch {
case err == nil:
owner.Idp = attr
case isAttrUnset(err), isNotFound(err):
case xattrs.IsAttrUnset(err), xattrs.IsNotExist(err):
fallthrough
default:
return nil, err
Expand All @@ -357,7 +363,7 @@ func (n *Node) Owner() (*userpb.UserId, error) {
switch {
case err == nil:
owner.Type = utils.UserTypeMap(attr)
case isAttrUnset(err), isNotFound(err):
case xattrs.IsAttrUnset(err), xattrs.IsNotExist(err):
fallthrough
default:
// TODO the user type defaults to invalid, which is the case
Expand Down Expand Up @@ -405,6 +411,11 @@ func (n *Node) LockFilePath() string {
return n.InternalPath() + ".lock"
}

// LockFilePath returns the internal path of the lock file of the node
func (n *Node) LockFilePath() string {
return n.lu.InternalPath(n.ID) + ".lock"
}

// CalculateEtag returns a hash of fileid + tmtime (or mtime)
func CalculateEtag(nodeID string, tmTime time.Time) (string, error) {
return calculateEtag(nodeID, tmTime)
Expand Down Expand Up @@ -705,9 +716,9 @@ func readChecksumIntoResourceChecksum(ctx context.Context, nodePath, algo string
Type: storageprovider.PKG2GRPCXS(algo),
Sum: hex.EncodeToString([]byte(v)),
}
case isAttrUnset(err):
case xattrs.IsAttrUnset(err):
appctx.GetLogger(ctx).Debug().Err(err).Str("nodepath", nodePath).Str("algorithm", algo).Msg("checksum not set")
case isNotFound(err):
case xattrs.IsNotExist(err):
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", nodePath).Str("algorithm", algo).Msg("file not fount")
default:
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", nodePath).Str("algorithm", algo).Msg("could not read checksum")
Expand All @@ -727,9 +738,9 @@ func readChecksumIntoOpaque(ctx context.Context, nodePath, algo string, ri *prov
Decoder: "plain",
Value: []byte(hex.EncodeToString([]byte(v))),
}
case isAttrUnset(err):
case xattrs.IsAttrUnset(err):
appctx.GetLogger(ctx).Debug().Err(err).Str("nodepath", nodePath).Str("algorithm", algo).Msg("checksum not set")
case isNotFound(err):
case xattrs.IsNotExist(err):
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", nodePath).Str("algorithm", algo).Msg("file not fount")
default:
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", nodePath).Str("algorithm", algo).Msg("could not read checksum")
Expand Down Expand Up @@ -759,9 +770,9 @@ func readQuotaIntoOpaque(ctx context.Context, nodePath string, ri *provider.Reso
} else {
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", nodePath).Str("quota", v).Msg("malformed quota")
}
case isAttrUnset(err):
case xattrs.IsAttrUnset(err):
appctx.GetLogger(ctx).Debug().Err(err).Str("nodepath", nodePath).Msg("quota not set")
case isNotFound(err):
case xattrs.IsNotExist(err):
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", nodePath).Msg("file not found when reading quota")
default:
appctx.GetLogger(ctx).Error().Err(err).Str("nodepath", nodePath).Msg("could not read quota")
Expand Down Expand Up @@ -886,7 +897,7 @@ func (n *Node) ReadUserPermissions(ctx context.Context, u *userpb.User) (ap prov
switch {
case err == nil:
AddPermissions(&ap, g.GetPermissions())
case isAttrUnset(err):
case xattrs.IsAttrUnset(err):
err = nil
appctx.GetLogger(ctx).Error().Interface("node", n).Str("grant", grantees[i]).Interface("grantees", grantees).Msg("grant vanished from node after listing")
// continue with next segment
Expand Down
15 changes: 1 addition & 14 deletions pkg/storage/utils/decomposedfs/node/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package node
import (
"context"
"strings"
"syscall"

userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand All @@ -30,7 +29,6 @@ import (
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/xattrs"
"github.com/cs3org/reva/pkg/utils"
"github.com/pkg/errors"
"github.com/pkg/xattr"
)

// NoPermissions represents an empty set of permissions
Expand Down Expand Up @@ -252,7 +250,7 @@ func nodeHasPermission(ctx context.Context, cn *Node, groupsMap map[string]bool,
if check(g.GetPermissions()) {
return true
}
case isAttrUnset(err):
case xattrs.IsAttrUnset(err):
appctx.GetLogger(ctx).Error().Interface("node", cn.ID).Str("grant", grantees[i]).Interface("grantees", grantees).Msg("grant vanished from node after listing")
default:
appctx.GetLogger(ctx).Error().Err(err).Interface("node", cn.ID).Str("grant", grantees[i]).Msg("error reading permissions")
Expand Down Expand Up @@ -290,14 +288,3 @@ func (p *Permissions) getUserAndPermissions(ctx context.Context, n *Node) (*user
}
return u, nil
}

// The os not exists error is buried inside the xattr error,
// so we cannot just use os.IsNotExists().
func isNotFound(err error) bool {
if xerr, ok := err.(*xattr.Error); ok {
if serr, ok2 := xerr.Err.(syscall.Errno); ok2 {
return serr == syscall.ENOENT
}
}
return false
}
37 changes: 0 additions & 37 deletions pkg/storage/utils/decomposedfs/node/permissions_darwin.go

This file was deleted.

Loading

0 comments on commit 752c692

Please sign in to comment.