Skip to content

Commit

Permalink
update expected failures, continue propagating on minor errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Feb 3, 2021
1 parent 0336464 commit 0c6c3d4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 39 deletions.
4 changes: 2 additions & 2 deletions changelog/unreleased/ocis-quota.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Enhancement: quota handling and tree accounting
Enhancement: quota querying and tree accounting

The ocs api now returns the user quota for the users home storage. Forthermore, the ocis driver we now expose the quota and propagate tree size changes.
The ocs api now returns the user quota for the users home storage. Furthermore, the ocis storage driver now reads the quota from the extended attributes of the user home or root node and implements tree size accounting. Finally, ocdav PROPFINDS now handle the `DAV:quota-used-bytes` and `DAV:quote-available-bytes` properties.

https://github.com/cs3org/reva/pull/1405
51 changes: 21 additions & 30 deletions pkg/storage/fs/ocis/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/pkg/xattr"
"github.com/rs/zerolog/log"
)

// Tree manages a hierarchical tree
Expand Down Expand Up @@ -301,12 +300,12 @@ func (t *Tree) Delete(ctx context.Context, n *Node) (err error) {

// Propagate propagates changes to the root of the tree
func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
sublog := appctx.GetLogger(ctx).With().Interface("node", n).Logger()
if !t.lu.Options.TreeTimeAccounting && !t.lu.Options.TreeSizeAccounting {
// no propagation enabled
log.Debug().Msg("propagation disabled")
sublog.Debug().Msg("propagation disabled")
return
}
log := appctx.GetLogger(ctx)

// is propagation enabled for the parent node?

Expand All @@ -320,16 +319,18 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {

// we loop until we reach the root
for err == nil && n.ID != root.ID {
log.Debug().Interface("node", n).Msg("propagating")
sublog.Debug().Msg("propagating")

// make n the parent or break the loop
if n, err = n.Parent(); err != nil {
break
}

sublog = sublog.With().Interface("node", n).Logger()

// TODO none, sync and async?
if !n.HasPropagation() {
log.Debug().Interface("node", n).Str("attr", propagationAttr).Msg("propagation attribute not set or unreadable, not propagating")
sublog.Debug().Str("attr", propagationAttr).Msg("propagation attribute not set or unreadable, not propagating")
// if the attribute is not set treat it as false / none / no propagation
return nil
}
Expand All @@ -343,20 +344,16 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
switch {
case err != nil:
// missing attribute, or invalid format, overwrite
log.Debug().Err(err).
Interface("node", n).
Msg("could not read tmtime attribute, overwriting")
sublog.Debug().Err(err).Msg("could not read tmtime attribute, overwriting")
updateSyncTime = true
case tmTime.Before(sTime):
log.Debug().
Interface("node", n).
sublog.Debug().
Time("tmtime", tmTime).
Time("stime", sTime).
Msg("parent tmtime is older than node mtime, updating")
updateSyncTime = true
default:
log.Debug().
Interface("node", n).
sublog.Debug().
Time("tmtime", tmTime).
Time("stime", sTime).
Dur("delta", sTime.Sub(tmTime)).
Expand All @@ -366,14 +363,14 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
if updateSyncTime {
// update the tree time of the parent node
if err = n.SetTMTime(sTime); err != nil {
log.Error().Err(err).Interface("node", n).Time("tmtime", sTime).Msg("could not update tmtime of parent node")
return
sublog.Error().Err(err).Time("tmtime", sTime).Msg("could not update tmtime of parent node")
} else {
sublog.Debug().Time("tmtime", sTime).Msg("updated tmtime of parent node")
}
log.Debug().Interface("node", n).Time("tmtime", sTime).Msg("updated tmtime of parent node")
}

if err := n.UnsetTempEtag(); err != nil {
log.Error().Err(err).Interface("node", n).Msg("could not remove temporary etag attribute")
sublog.Error().Err(err).Msg("could not remove temporary etag attribute")
}

}
Expand All @@ -386,27 +383,23 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
var treeSize, calculatedTreeSize uint64
calculatedTreeSize, err = n.CalculateTreeSize(ctx)
if err != nil {
return
continue
}

treeSize, err = n.GetTreeSize()
switch {
case err != nil:
// missing attribute, or invalid format, overwrite
log.Debug().Err(err).
Interface("node", n).
Msg("could not read treesize attribute, overwriting")
sublog.Debug().Err(err).Msg("could not read treesize attribute, overwriting")
updateTreeSize = true
case treeSize != calculatedTreeSize:
log.Debug().
Interface("node", n).
sublog.Debug().
Uint64("treesize", treeSize).
Uint64("calculatedTreeSize", calculatedTreeSize).
Msg("parent treesize is different then calculated treesize, updating")
updateTreeSize = true
default:
log.Debug().
Interface("node", n).
sublog.Debug().
Uint64("treesize", treeSize).
Uint64("calculatedTreeSize", calculatedTreeSize).
Msg("parent size matches calculated size, not updating")
Expand All @@ -415,17 +408,15 @@ func (t *Tree) Propagate(ctx context.Context, n *Node) (err error) {
if updateTreeSize {
// update the tree time of the parent node
if err = n.SetTreeSize(calculatedTreeSize); err != nil {
log.Error().Err(err).Interface("node", n).Uint64("calculatedTreeSize", calculatedTreeSize).Msg("could not update treesize of parent node")
return
sublog.Error().Err(err).Uint64("calculatedTreeSize", calculatedTreeSize).Msg("could not update treesize of parent node")
} else {
sublog.Debug().Uint64("calculatedTreeSize", calculatedTreeSize).Msg("updated treesize of parent node")
}
log.Debug().Interface("node", n).Uint64("calculatedTreeSize", calculatedTreeSize).Msg("updated treesize of parent node")
}
}

}
if err != nil {
log.Error().Err(err).Interface("node", n).Msg("error propagating")
return
sublog.Error().Err(err).Msg("error propagating")
}
return
}
11 changes: 6 additions & 5 deletions tests/acceptance/expected-failures-on-OCIS-storage.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Scenarios from ownCloud10 core API tests that are expected to fail with OCIS storage

### File
Basic file management like up and download, move, copy, properties, trash, versions and chunking.
Basic file management like up and download, move, copy, properties, quota, trash, versions and chunking.

#### [Implement Trashbin Feature for ocis storage](https://github.com/owncloud/product/issues/209)

Expand Down Expand Up @@ -316,9 +316,6 @@ Scenario Outline: try to create a folder with a name of an existing file
### [Different webdav properties from core](https://github.com/owncloud/ocis/issues/1302)
- [apiWebdavProperties2/getFileProperties.feature:327](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L327)
- [apiWebdavProperties2/getFileProperties.feature:328](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L328)
Scenario Outline: Propfind the size of a folder using webdav api `Property "oc:size" found with value "10", expected "#^0$#" or "#^0$#"`
- [apiWebdavProperties2/getFileProperties.feature:376](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L376)
- [apiWebdavProperties2/getFileProperties.feature:377](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L377)
Scenario Outline: Propfind the permissions on a file using webdav api `Property "oc:permissions" found with value "DNVWR", expected "/RM{0,1}DNVW/"`
- [apiWebdavProperties2/getFileProperties.feature:441](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L441)
- [apiWebdavProperties2/getFileProperties.feature:442](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L442)
Expand Down Expand Up @@ -1174,6 +1171,7 @@ File and sync features in a shared scenario
- [apiSharePublicLink2/uploadToPublicLinkShare.feature:66](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/uploadToPublicLinkShare.feature#L66)

#### [Set quota over settings](https://github.com/owncloud/ocis/issues/1290)
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiSharePublicLink2/uploadToPublicLinkShare.feature:148](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/uploadToPublicLinkShare.feature#L148)
- [apiSharePublicLink2/uploadToPublicLinkShare.feature:158](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/uploadToPublicLinkShare.feature#L158)
- [apiSharePublicLink2/uploadToPublicLinkShare.feature:167](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/uploadToPublicLinkShare.feature#L167)
Expand Down Expand Up @@ -1381,6 +1379,7 @@ Scenario Outline: delete a folder when there is a default folder for received sh
- [apiWebdavProperties1/copyFile.feature:475](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties1/copyFile.feature#L475)

#### [quota query](https://github.com/owncloud/ocis/issues/1313)
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiMain/quota.feature:41](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L41) Scenario: Uploading a file in received folder having enough quota
- [apiMain/quota.feature:54](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L54) Scenario: Uploading a file in received folder having insufficient quota
- [apiMain/quota.feature:68](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L68) Scenario: Overwriting a file in received folder having enough quota
Expand Down Expand Up @@ -1413,6 +1412,7 @@ Scenario Outline: Retrieving folder quota when quota is set and a file was recei
- [apiWebdavProperties2/getFileProperties.feature:233](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L233)

#### [changing user quota gives ocs status 103 / Cannot set quota](https://github.com/owncloud/product/issues/247)
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiShareOperationsToShares/uploadToShare.feature:162](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares/uploadToShare.feature#L162)
- [apiShareOperationsToShares/uploadToShare.feature:163](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares/uploadToShare.feature#L163)
- [apiShareOperationsToShares/uploadToShare.feature:181](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares/uploadToShare.feature#L181)
Expand Down Expand Up @@ -1831,7 +1831,7 @@ User and group management features
- [apiProvisioning-v2/editUser.feature:47](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiProvisioning-v2/editUser.feature#L47)

#### [quota query](https://github.com/owncloud/ocis/issues/1313)
_getting and setting quota_
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiMain/quota.feature:9](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L9) Scenario: Uploading a file as owner having enough quota
- [apiMain/quota.feature:16](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L16) Scenario: Uploading a file as owner having insufficient quota
- [apiMain/quota.feature:23](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L23) Scenario: Overwriting a file as owner having enough quota
Expand All @@ -1844,6 +1844,7 @@ Scenario Outline: Retrieving folder quota when quota is set
- [apiWebdavProperties1/getQuota.feature:28](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties1/getQuota.feature#L28)

#### [changing user quota gives ocs status 103 / Cannot set quota](https://github.com/owncloud/product/issues/247)
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiProvisioning-v1/editUser.feature:56](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiProvisioning-v1/editUser.feature#L56)
- [apiProvisioning-v1/editUser.feature:122](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiProvisioning-v1/editUser.feature#L122)
- [apiProvisioning-v2/editUser.feature:56](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiProvisioning-v2/editUser.feature#L56)
Expand Down
8 changes: 6 additions & 2 deletions tests/acceptance/expected-failures-on-OWNCLOUD-storage.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Scenarios from ownCloud10 core API tests that are expected to fail with owncloud storage

### File
Basic file management like up and download, move, copy, properties, trash, versions and chunking.
Basic file management like up and download, move, copy, properties, quota, trash, versions and chunking.

#### [Implement Trashbin Feature for ocis storage](https://github.com/owncloud/product/issues/209)
- [apiWebdavEtagPropagation2/restoreFromTrash.feature:48](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavEtagPropagation2/restoreFromTrash.feature#L48)
Expand Down Expand Up @@ -1182,6 +1182,7 @@ The following scenarios fail on OWNCLOUD storage but not on OCIS storage:
- [apiSharePublicLink2/uploadToPublicLinkShare.feature:66](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/uploadToPublicLinkShare.feature#L66)

#### [Set quota over settings](https://github.com/owncloud/ocis/issues/1290)
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiSharePublicLink2/uploadToPublicLinkShare.feature:148](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/uploadToPublicLinkShare.feature#L148)
- [apiSharePublicLink2/uploadToPublicLinkShare.feature:158](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/uploadToPublicLinkShare.feature#L158)
- [apiSharePublicLink2/uploadToPublicLinkShare.feature:167](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSharePublicLink2/uploadToPublicLinkShare.feature#L167)
Expand Down Expand Up @@ -1483,6 +1484,7 @@ Scenario Outline: delete a folder when there is a default folder for received sh
- [apiWebdavProperties1/copyFile.feature:475](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties1/copyFile.feature#L475)

#### [quota query](https://github.com/owncloud/ocis/issues/1313)
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiMain/quota.feature:41](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L41) Scenario: Uploading a file in received folder having enough quota
- [apiMain/quota.feature:54](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L54) Scenario: Uploading a file in received folder having insufficient quota
- [apiMain/quota.feature:68](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L68) Scenario: Overwriting a file in received folder having enough quota
Expand Down Expand Up @@ -1520,6 +1522,7 @@ The following scenarios fail on OWNCLOUD storage but not on OCIS storage:
- [apiWebdavProperties2/getFileProperties.feature:233](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties2/getFileProperties.feature#L233)

#### [changing user quota gives ocs status 103 / Cannot set quota](https://github.com/owncloud/product/issues/247)
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiShareOperationsToShares/uploadToShare.feature:162](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares/uploadToShare.feature#L162)
- [apiShareOperationsToShares/uploadToShare.feature:163](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares/uploadToShare.feature#L163)
- [apiShareOperationsToShares/uploadToShare.feature:181](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareOperationsToShares/uploadToShare.feature#L181)
Expand Down Expand Up @@ -1947,7 +1950,7 @@ special character username not valid
- [apiProvisioning-v2/editUser.feature:47](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiProvisioning-v2/editUser.feature#L47)

#### [quota query](https://github.com/owncloud/ocis/issues/1313)
_getting and setting quota_
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiMain/quota.feature:9](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L9) Scenario: Uploading a file as owner having enough quota
- [apiMain/quota.feature:16](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L16) Scenario: Uploading a file as owner having insufficient quota
- [apiMain/quota.feature:23](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/quota.feature#L23) Scenario: Overwriting a file as owner having enough quota
Expand All @@ -1960,6 +1963,7 @@ _getting and setting quota_
- [apiWebdavProperties1/getQuota.feature:28](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavProperties1/getQuota.feature#L28)

#### [changing user quota gives ocs status 103 / Cannot set quota](https://github.com/owncloud/product/issues/247)
_requires a [CS3 user provisioning api that can update the quota for a user](https://github.com/cs3org/cs3apis/pull/95#issuecomment-772780683)_
- [apiProvisioning-v1/editUser.feature:56](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiProvisioning-v1/editUser.feature#L56)
- [apiProvisioning-v1/editUser.feature:122](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiProvisioning-v1/editUser.feature#L122)
- [apiProvisioning-v2/editUser.feature:56](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiProvisioning-v2/editUser.feature#L56)
Expand Down

0 comments on commit 0c6c3d4

Please sign in to comment.