[#1969] local_object_storage: Move ErrObjectIsExpired to another package

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-31 10:08:30 +03:00 committed by fyrchik
parent 56de2f1363
commit 34501685b7
10 changed files with 15 additions and 22 deletions

View file

@ -1,10 +0,0 @@
package object
import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
)
// ErrObjectIsExpired is returned when the requested object's
// epoch is less than the current one. Such objects are considered
// as removed and should not be returned from the Storage Engine.
var ErrObjectIsExpired = logicerr.New("object is expired")

View file

@ -211,7 +211,7 @@ func TestCounters_Expired(t *testing.T) {
for _, o := range oo {
_, err := metaGet(db, o, true)
require.ErrorIs(t, err, objectcore.ErrObjectIsExpired)
require.ErrorIs(t, err, meta.ErrObjectIsExpired)
}
// 3. inhuming an expired object with GCMark (like it would

View file

@ -3,9 +3,15 @@ package meta
import (
"errors"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
)
// ErrObjectIsExpired is returned when the requested object's
// epoch is less than the current one. Such objects are considered
// as removed and should not be returned from the Storage Engine.
var ErrObjectIsExpired = logicerr.New("object is expired")
// IsErrRemoved checks if error returned by Shard Exists/Get/Put method
// corresponds to removed object.
func IsErrRemoved(err error) bool {

View file

@ -5,7 +5,6 @@ import (
"strconv"
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -64,7 +63,7 @@ func (db *DB) exists(tx *bbolt.Tx, addr oid.Address, currEpoch uint64) (exists b
case 2:
return false, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
case 3:
return false, object.ErrObjectIsExpired
return false, ErrObjectIsExpired
}
objKey := objectKey(addr.Object(), make([]byte, objectKeySize))

View file

@ -177,7 +177,7 @@ func TestDB_Exists(t *testing.T) {
checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) {
gotObj, err := metaExists(db, object.AddressOf(exp))
require.False(t, gotObj)
require.ErrorIs(t, err, object.ErrObjectIsExpired)
require.ErrorIs(t, err, meta.ErrObjectIsExpired)
gotObj, err = metaExists(db, object.AddressOf(nonExp))
require.True(t, gotObj)

View file

@ -3,7 +3,6 @@ package meta
import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -71,7 +70,7 @@ func (db *DB) get(tx *bbolt.Tx, addr oid.Address, key []byte, checkStatus, raw b
case 2:
return nil, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
case 3:
return nil, object.ErrObjectIsExpired
return nil, ErrObjectIsExpired
}
}

View file

@ -139,7 +139,7 @@ func TestDB_Get(t *testing.T) {
checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) {
gotExp, err := metaGet(db, object.AddressOf(exp), false)
require.Nil(t, gotExp)
require.ErrorIs(t, err, object.ErrObjectIsExpired)
require.ErrorIs(t, err, meta.ErrObjectIsExpired)
gotNonExp, err := metaGet(db, object.AddressOf(nonExp), false)
require.NoError(t, err)

View file

@ -223,7 +223,7 @@ func (s *Shard) refillMetabase() error {
mPrm.SetStorageID(descriptor)
_, err := s.metaBase.Put(mPrm)
if err != nil && !meta.IsErrRemoved(err) && !errors.Is(err, object.ErrObjectIsExpired) {
if err != nil && !meta.IsErrRemoved(err) && !errors.Is(err, meta.ErrObjectIsExpired) {
return err
}

View file

@ -3,7 +3,7 @@ package shard
import (
"errors"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
)
@ -28,5 +28,5 @@ func IsErrOutOfRange(err error) bool {
// IsErrObjectExpired checks if an error returned by Shard corresponds to
// expired object.
func IsErrObjectExpired(err error) bool {
return errors.Is(err, object.ErrObjectIsExpired)
return errors.Is(err, meta.ErrObjectIsExpired)
}

View file

@ -3,7 +3,6 @@ package writecache
import (
"errors"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
@ -67,7 +66,7 @@ func (c *cache) isFlushed(addr oid.Address) bool {
mRes, err := c.metabase.Exists(existsPrm)
if err != nil {
return errors.Is(err, object.ErrObjectIsExpired) || errors.As(err, new(apistatus.ObjectAlreadyRemoved))
return errors.Is(err, meta.ErrObjectIsExpired) || errors.As(err, new(apistatus.ObjectAlreadyRemoved))
}
if !mRes.Exists() {