From 9326e3bea656f157076787c8e4fda3ba2df1674c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 3 Feb 2021 20:10:40 +0000 Subject: [PATCH] update expected failures, continue propagating on minor errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/storage/fs/ocis/tree.go | 51 ++++++++----------- .../expected-failures-on-OCIS-storage.md | 3 -- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/pkg/storage/fs/ocis/tree.go b/pkg/storage/fs/ocis/tree.go index c38e84e2726..0fed4172866 100644 --- a/pkg/storage/fs/ocis/tree.go +++ b/pkg/storage/fs/ocis/tree.go @@ -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 @@ -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? @@ -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 } @@ -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)). @@ -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") } } @@ -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") @@ -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 } diff --git a/tests/acceptance/expected-failures-on-OCIS-storage.md b/tests/acceptance/expected-failures-on-OCIS-storage.md index 74bfc368696..878a094bd45 100644 --- a/tests/acceptance/expected-failures-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-on-OCIS-storage.md @@ -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)