forked from TrueCloudLab/frostfs-node
[#1969] local_object_storage: Move ErrObjectIsExpired
to another package
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
56de2f1363
commit
34501685b7
10 changed files with 15 additions and 22 deletions
|
@ -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")
|
|
|
@ -211,7 +211,7 @@ func TestCounters_Expired(t *testing.T) {
|
||||||
|
|
||||||
for _, o := range oo {
|
for _, o := range oo {
|
||||||
_, err := metaGet(db, o, true)
|
_, 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
|
// 3. inhuming an expired object with GCMark (like it would
|
||||||
|
|
|
@ -3,9 +3,15 @@ package meta
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
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
|
// IsErrRemoved checks if error returned by Shard Exists/Get/Put method
|
||||||
// corresponds to removed object.
|
// corresponds to removed object.
|
||||||
func IsErrRemoved(err error) bool {
|
func IsErrRemoved(err error) bool {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object"
|
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"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
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:
|
case 2:
|
||||||
return false, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
|
return false, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
|
||||||
case 3:
|
case 3:
|
||||||
return false, object.ErrObjectIsExpired
|
return false, ErrObjectIsExpired
|
||||||
}
|
}
|
||||||
|
|
||||||
objKey := objectKey(addr.Object(), make([]byte, objectKeySize))
|
objKey := objectKey(addr.Object(), make([]byte, objectKeySize))
|
||||||
|
|
|
@ -177,7 +177,7 @@ func TestDB_Exists(t *testing.T) {
|
||||||
checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) {
|
checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) {
|
||||||
gotObj, err := metaExists(db, object.AddressOf(exp))
|
gotObj, err := metaExists(db, object.AddressOf(exp))
|
||||||
require.False(t, gotObj)
|
require.False(t, gotObj)
|
||||||
require.ErrorIs(t, err, object.ErrObjectIsExpired)
|
require.ErrorIs(t, err, meta.ErrObjectIsExpired)
|
||||||
|
|
||||||
gotObj, err = metaExists(db, object.AddressOf(nonExp))
|
gotObj, err = metaExists(db, object.AddressOf(nonExp))
|
||||||
require.True(t, gotObj)
|
require.True(t, gotObj)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package meta
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
|
||||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
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:
|
case 2:
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
|
return nil, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
|
||||||
case 3:
|
case 3:
|
||||||
return nil, object.ErrObjectIsExpired
|
return nil, ErrObjectIsExpired
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ func TestDB_Get(t *testing.T) {
|
||||||
checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) {
|
checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) {
|
||||||
gotExp, err := metaGet(db, object.AddressOf(exp), false)
|
gotExp, err := metaGet(db, object.AddressOf(exp), false)
|
||||||
require.Nil(t, gotExp)
|
require.Nil(t, gotExp)
|
||||||
require.ErrorIs(t, err, object.ErrObjectIsExpired)
|
require.ErrorIs(t, err, meta.ErrObjectIsExpired)
|
||||||
|
|
||||||
gotNonExp, err := metaGet(db, object.AddressOf(nonExp), false)
|
gotNonExp, err := metaGet(db, object.AddressOf(nonExp), false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -223,7 +223,7 @@ func (s *Shard) refillMetabase() error {
|
||||||
mPrm.SetStorageID(descriptor)
|
mPrm.SetStorageID(descriptor)
|
||||||
|
|
||||||
_, err := s.metaBase.Put(mPrm)
|
_, 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package shard
|
||||||
import (
|
import (
|
||||||
"errors"
|
"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"
|
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
|
// IsErrObjectExpired checks if an error returned by Shard corresponds to
|
||||||
// expired object.
|
// expired object.
|
||||||
func IsErrObjectExpired(err error) bool {
|
func IsErrObjectExpired(err error) bool {
|
||||||
return errors.Is(err, object.ErrObjectIsExpired)
|
return errors.Is(err, meta.ErrObjectIsExpired)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package writecache
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
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)
|
mRes, err := c.metabase.Exists(existsPrm)
|
||||||
if err != nil {
|
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() {
|
if !mRes.Exists() {
|
||||||
|
|
Loading…
Reference in a new issue