From e8c5f03c30d4d52fd247b8122f310cba0077ed73 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 28 Oct 2022 14:55:21 +0400 Subject: [PATCH] [#1905] shard: Don't log read-only errors of write-cache There is no need to log `writecache.ErrReadOnly` errors in `Delete` method of the `Shard`. Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/shard/delete.go | 5 ++++- pkg/local_object_storage/writecache/writecache.go | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/shard/delete.go b/pkg/local_object_storage/shard/delete.go index 1cfba1e36d..e19f2c33d6 100644 --- a/pkg/local_object_storage/shard/delete.go +++ b/pkg/local_object_storage/shard/delete.go @@ -1,8 +1,11 @@ package shard import ( + "errors" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" "go.uber.org/zap" ) @@ -39,7 +42,7 @@ func (s *Shard) Delete(prm DeletePrm) (DeleteRes, error) { for i := range prm.addr { if s.hasWriteCache() { err := s.writeCache.Delete(prm.addr[i]) - if err != nil && !IsErrNotFound(err) { + if err != nil && !IsErrNotFound(err) && !errors.Is(err, writecache.ErrReadOnly) { s.log.Warn("can't delete object from write cache", zap.String("error", err.Error())) } } diff --git a/pkg/local_object_storage/writecache/writecache.go b/pkg/local_object_storage/writecache/writecache.go index 4d53c8a274..f5c3f88052 100644 --- a/pkg/local_object_storage/writecache/writecache.go +++ b/pkg/local_object_storage/writecache/writecache.go @@ -23,6 +23,12 @@ type Info struct { type Cache interface { Get(address oid.Address) (*object.Object, error) Head(oid.Address) (*object.Object, error) + // Delete removes object referenced by the given oid.Address from the + // Cache. Returns any error encountered that prevented the object to be + // removed. + // + // Returns apistatus.ObjectNotFound if object is missing in the Cache. + // Returns ErrReadOnly if the Cache is currently in the read-only mode. Delete(oid.Address) error Iterate(IterationPrm) error Put(common.PutPrm) (common.PutRes, error)