Skip to content

Commit

Permalink
Fix/object exist operation logs (#2955)
Browse files Browse the repository at this point in the history
  • Loading branch information
cthulhu-rider authored Oct 3, 2024
2 parents 208d7c6 + 14c7426 commit f33949e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 5 additions & 1 deletion pkg/local_object_storage/engine/inhume.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ func (e *StorageEngine) inhumeAddr(addr oid.Address, prm shard.InhumePrm) (bool,

res, err := sh.Exists(existPrm)
if err != nil {
if shard.IsErrNotFound(err) {
return false
}

if shard.IsErrRemoved(err) || shard.IsErrObjectExpired(err) {
// inhumed once - no need to be inhumed again
ok = true
Expand All @@ -162,7 +166,7 @@ func (e *StorageEngine) inhumeAddr(addr oid.Address, prm shard.InhumePrm) (bool,

var siErr *objectSDK.SplitInfoError
if !errors.As(err, &siErr) {
e.reportShardError(sh, "could not check for presents in shard", err)
e.reportShardError(sh, "could not check for presence in shard", err, zap.Stringer("addr", addr))
return
}

Expand Down
18 changes: 18 additions & 0 deletions pkg/local_object_storage/engine/inhume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -153,4 +154,21 @@ func TestStorageEngine_Inhume(t *testing.T) {
_, err = wrongShard.Get(getPrm)
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
})

t.Run("inhuming object twice", func(t *testing.T) {
addr := oidtest.Address()

e := testNewEngineWithShardNum(t, 3)
defer e.Close()

var inhumePrm InhumePrm
inhumePrm.MarkAsGarbage(addr)

_, err := e.Inhume(inhumePrm)
require.NoError(t, err)

// object is marked as garbage but marking it again should not be a problem
_, err = e.Inhume(inhumePrm)
require.NoError(t, err)
})
}
6 changes: 3 additions & 3 deletions pkg/local_object_storage/shard/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
// IsErrNotFound checks if error returned by Shard Get/Head/GetRange method
// corresponds to missing object.
func IsErrNotFound(err error) bool {
return errors.As(err, new(apistatus.ObjectNotFound))
return errors.Is(err, apistatus.ErrObjectNotFound)
}

// IsErrRemoved checks if error returned by Shard Exists/Get/Head/GetRange method
// corresponds to removed object.
func IsErrRemoved(err error) bool {
return errors.As(err, new(apistatus.ObjectAlreadyRemoved))
return errors.Is(err, apistatus.ErrObjectAlreadyRemoved)
}

// IsErrOutOfRange checks if an error returned by Shard GetRange method
// corresponds to exceeding the object bounds.
func IsErrOutOfRange(err error) bool {
return errors.As(err, new(apistatus.ObjectOutOfRange))
return errors.Is(err, apistatus.ErrObjectOutOfRange)
}

// IsErrObjectExpired checks if an error returned by Shard corresponds to
Expand Down

0 comments on commit f33949e

Please sign in to comment.