[#481] Update frostfs-sdk-go and error pointer receivers #567
77 changed files with 263 additions and 311 deletions
|
@ -109,7 +109,7 @@ type GetContainerPrm struct {
|
||||||
|
|
||||||
// SetContainer sets identifier of the container to be read.
|
// SetContainer sets identifier of the container to be read.
|
||||||
func (x *GetContainerPrm) SetContainer(id cid.ID) {
|
func (x *GetContainerPrm) SetContainer(id cid.ID) {
|
||||||
x.cliPrm.SetContainer(id)
|
*x.cliPrm.ContainerID = id
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetContainerRes groups the resulting values of GetContainer operation.
|
// GetContainerRes groups the resulting values of GetContainer operation.
|
||||||
|
|
|
@ -208,7 +208,7 @@ func newCachedContainerStorage(v container.Source, ttl time.Duration) ttlContain
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s ttlContainerStorage) handleRemoval(cnr cid.ID) {
|
func (s ttlContainerStorage) handleRemoval(cnr cid.ID) {
|
||||||
s.set(cnr, nil, apistatus.ContainerNotFound{})
|
s.set(cnr, nil, new(apistatus.ContainerNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns container value from the cache. If value is missing in the cache
|
// Get returns container value from the cache. If value is missing in the cache
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -6,7 +6,7 @@ require (
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.15.1-0.20230802075510-964c3edb3f44
|
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.15.1-0.20230802075510-964c3edb3f44
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230627134746-36f3d39c406a
|
git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230627134746-36f3d39c406a
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20230531082742-c97d21411eb6
|
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20230531082742-c97d21411eb6
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230802090410-95b987b818d9
|
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230804083501-3dc8129ed794
|
||||||
git.frostfs.info/TrueCloudLab/hrw v1.2.1
|
git.frostfs.info/TrueCloudLab/hrw v1.2.1
|
||||||
git.frostfs.info/TrueCloudLab/tzhash v1.8.0
|
git.frostfs.info/TrueCloudLab/tzhash v1.8.0
|
||||||
github.com/cheggaaa/pb v1.0.29
|
github.com/cheggaaa/pb v1.0.29
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -1,9 +1,6 @@
|
||||||
package container
|
package container
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
|
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
|
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
|
||||||
|
@ -37,12 +34,6 @@ type Source interface {
|
||||||
Get(cid.ID) (*Container, error)
|
Get(cid.ID) (*Container, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsErrNotFound checks if the error returned by Source.Get corresponds
|
|
||||||
// to the missing container.
|
|
||||||
func IsErrNotFound(err error) bool {
|
|
||||||
return errors.As(err, new(apistatus.ContainerNotFound))
|
|
||||||
}
|
|
||||||
|
|
||||||
// EACL groups information about the FrostFS container's extended ACL stored in
|
// EACL groups information about the FrostFS container's extended ACL stored in
|
||||||
// the FrostFS network.
|
// the FrostFS network.
|
||||||
type EACL struct {
|
type EACL struct {
|
||||||
|
|
|
@ -282,7 +282,7 @@ func (c *testContainerClient) Get(cid []byte) (*containercore.Container, error)
|
||||||
if cont, found := c.get[key]; found {
|
if cont, found := c.get[key]; found {
|
||||||
return cont, nil
|
return cont, nil
|
||||||
}
|
}
|
||||||
return nil, apistatus.ContainerNotFound{}
|
return nil, new(apistatus.ContainerNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
type testIDClient struct {
|
type testIDClient struct {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger/test"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger/test"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -77,7 +78,7 @@ func TestBlobovnicza(t *testing.T) {
|
||||||
require.NoError(t, blz.Init())
|
require.NoError(t, blz.Init())
|
||||||
|
|
||||||
// try to read non-existent address
|
// try to read non-existent address
|
||||||
testGet(t, blz, oidtest.Address(), nil, IsErrNotFound)
|
testGet(t, blz, oidtest.Address(), nil, client.IsErrObjectNotFound)
|
||||||
|
|
||||||
filled := uint64(15 * 1 << 10)
|
filled := uint64(15 * 1 << 10)
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ func TestBlobovnicza(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// should return 404
|
// should return 404
|
||||||
testGet(t, blz, addr, nil, IsErrNotFound)
|
testGet(t, blz, addr, nil, client.IsErrObjectNotFound)
|
||||||
|
|
||||||
// fill Blobovnicza fully
|
// fill Blobovnicza fully
|
||||||
for ; filled < sizeLim; filled += objSizeLim {
|
for ; filled < sizeLim; filled += objSizeLim {
|
||||||
|
|
|
@ -77,9 +77,7 @@ func (b *Blobovnicza) Delete(ctx context.Context, prm DeletePrm) (DeleteRes, err
|
||||||
})
|
})
|
||||||
|
|
||||||
if err == nil && !found {
|
if err == nil && !found {
|
||||||
var errNotFound apistatus.ObjectNotFound
|
return DeleteRes{}, new(apistatus.ObjectNotFound)
|
||||||
|
|
||||||
return DeleteRes{}, errNotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeleteRes{}, err
|
return DeleteRes{}, err
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package blobovnicza
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsErrNotFound checks if the error returned by Blobovnicza Get/Delete method
|
|
||||||
// corresponds to the missing object.
|
|
||||||
func IsErrNotFound(err error) bool {
|
|
||||||
return errors.As(err, new(apistatus.ObjectNotFound))
|
|
||||||
}
|
|
|
@ -72,9 +72,7 @@ func (b *Blobovnicza) Get(ctx context.Context, prm GetPrm) (GetRes, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if data == nil {
|
if data == nil {
|
||||||
var errNotFound apistatus.ObjectNotFound
|
return GetRes{}, new(apistatus.ObjectNotFound)
|
||||||
|
|
||||||
return GetRes{}, errNotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetRes{
|
return GetRes{
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
@ -69,7 +70,7 @@ func (b *Blobovniczas) Delete(ctx context.Context, prm common.DeletePrm) (res co
|
||||||
|
|
||||||
res, err = b.deleteObjectFromLevel(ctx, bPrm, p, !ok)
|
res, err = b.deleteObjectFromLevel(ctx, bPrm, p, !ok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !blobovnicza.IsErrNotFound(err) {
|
if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromLevel,
|
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromLevel,
|
||||||
zap.String("level", p),
|
zap.String("level", p),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -89,7 +90,7 @@ func (b *Blobovniczas) Delete(ctx context.Context, prm common.DeletePrm) (res co
|
||||||
|
|
||||||
if err == nil && !objectFound {
|
if err == nil && !objectFound {
|
||||||
// not found in any blobovnicza
|
// not found in any blobovnicza
|
||||||
return common.DeleteRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.DeleteRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
success = err == nil
|
success = err == nil
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ func (b *Blobovniczas) deleteObjectFromLevel(ctx context.Context, prm blobovnicz
|
||||||
if ok {
|
if ok {
|
||||||
if res, err := b.deleteObject(ctx, v, prm); err == nil {
|
if res, err := b.deleteObject(ctx, v, prm); err == nil {
|
||||||
return res, err
|
return res, err
|
||||||
} else if !blobovnicza.IsErrNotFound(err) {
|
} else if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromOpenedBlobovnicza,
|
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromOpenedBlobovnicza,
|
||||||
zap.String("path", blzPath),
|
zap.String("path", blzPath),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -128,7 +129,7 @@ func (b *Blobovniczas) deleteObjectFromLevel(ctx context.Context, prm blobovnicz
|
||||||
if ok && tryActive {
|
if ok && tryActive {
|
||||||
if res, err := b.deleteObject(ctx, active.blz, prm); err == nil {
|
if res, err := b.deleteObject(ctx, active.blz, prm); err == nil {
|
||||||
return res, err
|
return res, err
|
||||||
} else if !blobovnicza.IsErrNotFound(err) {
|
} else if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromActiveBlobovnicza,
|
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromActiveBlobovnicza,
|
||||||
zap.String("path", blzPath),
|
zap.String("path", blzPath),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -142,7 +143,7 @@ func (b *Blobovniczas) deleteObjectFromLevel(ctx context.Context, prm blobovnicz
|
||||||
// (Blobovniczas "after" the active one are empty anyway,
|
// (Blobovniczas "after" the active one are empty anyway,
|
||||||
// and it's pointless to open them).
|
// and it's pointless to open them).
|
||||||
if u64FromHexString(filepath.Base(blzPath)) > active.ind {
|
if u64FromHexString(filepath.Base(blzPath)) > active.ind {
|
||||||
return common.DeleteRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.DeleteRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// open blobovnicza (cached inside)
|
// open blobovnicza (cached inside)
|
||||||
|
|
|
@ -8,7 +8,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func isErrOutOfRange(err error) bool {
|
func isErrOutOfRange(err error) bool {
|
||||||
return errors.As(err, new(apistatus.ObjectOutOfRange))
|
var target *apistatus.ObjectOutOfRange
|
||||||
|
return errors.As(err, &target)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isLogical(err error) bool {
|
func isLogical(err error) bool {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobovnicza"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobovnicza"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -57,7 +58,7 @@ func (b *Blobovniczas) Exists(ctx context.Context, prm common.ExistsPrm) (common
|
||||||
|
|
||||||
_, err := b.getObjectFromLevel(ctx, gPrm, p, !ok)
|
_, err := b.getObjectFromLevel(ctx, gPrm, p, !ok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !blobovnicza.IsErrNotFound(err) {
|
if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
||||||
zap.String("level", p),
|
zap.String("level", p),
|
||||||
zap.String("error", err.Error()))
|
zap.String("error", err.Error()))
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
@ -69,7 +70,7 @@ func (b *Blobovniczas) Get(ctx context.Context, prm common.GetPrm) (res common.G
|
||||||
|
|
||||||
res, err = b.getObjectFromLevel(ctx, bPrm, p, !ok)
|
res, err = b.getObjectFromLevel(ctx, bPrm, p, !ok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !blobovnicza.IsErrNotFound(err) {
|
if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
||||||
zap.String("level", p),
|
zap.String("level", p),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -85,7 +86,7 @@ func (b *Blobovniczas) Get(ctx context.Context, prm common.GetPrm) (res common.G
|
||||||
|
|
||||||
if err == nil && res.Object == nil {
|
if err == nil && res.Object == nil {
|
||||||
// not found in any blobovnicza
|
// not found in any blobovnicza
|
||||||
return res, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return res, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
success = true
|
success = true
|
||||||
|
@ -107,7 +108,7 @@ func (b *Blobovniczas) getObjectFromLevel(ctx context.Context, prm blobovnicza.G
|
||||||
if ok {
|
if ok {
|
||||||
if res, err := b.getObject(ctx, v, prm); err == nil {
|
if res, err := b.getObject(ctx, v, prm); err == nil {
|
||||||
return res, err
|
return res, err
|
||||||
} else if !blobovnicza.IsErrNotFound(err) {
|
} else if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotReadObjectFromOpenedBlobovnicza,
|
b.log.Debug(logs.BlobovniczatreeCouldNotReadObjectFromOpenedBlobovnicza,
|
||||||
zap.String("path", blzPath),
|
zap.String("path", blzPath),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -127,7 +128,7 @@ func (b *Blobovniczas) getObjectFromLevel(ctx context.Context, prm blobovnicza.G
|
||||||
if ok && tryActive {
|
if ok && tryActive {
|
||||||
if res, err := b.getObject(ctx, active.blz, prm); err == nil {
|
if res, err := b.getObject(ctx, active.blz, prm); err == nil {
|
||||||
return res, err
|
return res, err
|
||||||
} else if !blobovnicza.IsErrNotFound(err) {
|
} else if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromActiveBlobovnicza,
|
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromActiveBlobovnicza,
|
||||||
zap.String("path", blzPath),
|
zap.String("path", blzPath),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -141,7 +142,7 @@ func (b *Blobovniczas) getObjectFromLevel(ctx context.Context, prm blobovnicza.G
|
||||||
// (Blobovniczas "after" the active one are empty anyway,
|
// (Blobovniczas "after" the active one are empty anyway,
|
||||||
// and it's pointless to open them).
|
// and it's pointless to open them).
|
||||||
if u64FromHexString(filepath.Base(blzPath)) > active.ind {
|
if u64FromHexString(filepath.Base(blzPath)) > active.ind {
|
||||||
return common.GetRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.GetRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// open blobovnicza (cached inside)
|
// open blobovnicza (cached inside)
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
@ -70,7 +71,7 @@ func (b *Blobovniczas) GetRange(ctx context.Context, prm common.GetRangePrm) (re
|
||||||
res, err = b.getRangeFromLevel(ctx, prm, p, !ok)
|
res, err = b.getRangeFromLevel(ctx, prm, p, !ok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
outOfBounds := isErrOutOfRange(err)
|
outOfBounds := isErrOutOfRange(err)
|
||||||
if !outOfBounds && !blobovnicza.IsErrNotFound(err) {
|
if !outOfBounds && !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
||||||
zap.String("level", p),
|
zap.String("level", p),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -91,7 +92,7 @@ func (b *Blobovniczas) GetRange(ctx context.Context, prm common.GetRangePrm) (re
|
||||||
|
|
||||||
if err == nil && !objectFound {
|
if err == nil && !objectFound {
|
||||||
// not found in any blobovnicza
|
// not found in any blobovnicza
|
||||||
return common.GetRangeRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.GetRangeRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -119,7 +120,7 @@ func (b *Blobovniczas) getRangeFromLevel(ctx context.Context, prm common.GetRang
|
||||||
isErrOutOfRange(err):
|
isErrOutOfRange(err):
|
||||||
return res, err
|
return res, err
|
||||||
default:
|
default:
|
||||||
if !blobovnicza.IsErrNotFound(err) {
|
if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotReadPayloadRangeFromOpenedBlobovnicza,
|
b.log.Debug(logs.BlobovniczatreeCouldNotReadPayloadRangeFromOpenedBlobovnicza,
|
||||||
zap.String("path", blzPath),
|
zap.String("path", blzPath),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -144,7 +145,7 @@ func (b *Blobovniczas) getRangeFromLevel(ctx context.Context, prm common.GetRang
|
||||||
isErrOutOfRange(err):
|
isErrOutOfRange(err):
|
||||||
return res, err
|
return res, err
|
||||||
default:
|
default:
|
||||||
if !blobovnicza.IsErrNotFound(err) {
|
if !client.IsErrObjectNotFound(err) {
|
||||||
b.log.Debug(logs.BlobovniczatreeCouldNotReadPayloadRangeFromActiveBlobovnicza,
|
b.log.Debug(logs.BlobovniczatreeCouldNotReadPayloadRangeFromActiveBlobovnicza,
|
||||||
zap.String("path", blzPath),
|
zap.String("path", blzPath),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
@ -159,7 +160,7 @@ func (b *Blobovniczas) getRangeFromLevel(ctx context.Context, prm common.GetRang
|
||||||
// (Blobovniczas "after" the active one are empty anyway,
|
// (Blobovniczas "after" the active one are empty anyway,
|
||||||
// and it's pointless to open them).
|
// and it's pointless to open them).
|
||||||
if u64FromHexString(filepath.Base(blzPath)) > active.ind {
|
if u64FromHexString(filepath.Base(blzPath)) > active.ind {
|
||||||
return common.GetRangeRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.GetRangeRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// open blobovnicza (cached inside)
|
// open blobovnicza (cached inside)
|
||||||
|
@ -202,7 +203,7 @@ func (b *Blobovniczas) getObjectRange(ctx context.Context, blz *blobovnicza.Blob
|
||||||
payload := obj.Payload()
|
payload := obj.Payload()
|
||||||
|
|
||||||
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
||||||
return common.GetRangeRes{}, logicerr.Wrap(apistatus.ObjectOutOfRange{})
|
return common.GetRangeRes{}, logicerr.Wrap(new(apistatus.ObjectOutOfRange))
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.GetRangeRes{
|
return common.GetRangeRes{
|
||||||
|
|
|
@ -3,12 +3,11 @@ package blobstor
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
)
|
)
|
||||||
|
@ -35,7 +34,7 @@ func (b *BlobStor) Delete(ctx context.Context, prm common.DeletePrm) (common.Del
|
||||||
if prm.StorageID == nil {
|
if prm.StorageID == nil {
|
||||||
for i := range b.storage {
|
for i := range b.storage {
|
||||||
res, err := b.storage[i].Storage.Delete(ctx, prm)
|
res, err := b.storage[i].Storage.Delete(ctx, prm)
|
||||||
if err == nil || !errors.As(err, new(apistatus.ObjectNotFound)) {
|
if err == nil || !client.IsErrObjectNotFound(err) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
success = true
|
success = true
|
||||||
logOp(b.log, deleteOp, prm.Address, b.storage[i].Storage.Type(), prm.StorageID)
|
logOp(b.log, deleteOp, prm.Address, b.storage[i].Storage.Type(), prm.StorageID)
|
||||||
|
|
|
@ -246,7 +246,7 @@ func (t *FSTree) Delete(ctx context.Context, prm common.DeletePrm) (common.Delet
|
||||||
|
|
||||||
err = os.Remove(p)
|
err = os.Remove(p)
|
||||||
if err != nil && os.IsNotExist(err) {
|
if err != nil && os.IsNotExist(err) {
|
||||||
err = logicerr.Wrap(apistatus.ObjectNotFound{})
|
err = logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
return common.DeleteRes{}, err
|
return common.DeleteRes{}, err
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ func (t *FSTree) Get(ctx context.Context, prm common.GetPrm) (common.GetRes, err
|
||||||
p := t.treePath(prm.Address)
|
p := t.treePath(prm.Address)
|
||||||
|
|
||||||
if _, err := os.Stat(p); os.IsNotExist(err) {
|
if _, err := os.Stat(p); os.IsNotExist(err) {
|
||||||
return common.GetRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.GetRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
var data []byte
|
var data []byte
|
||||||
|
@ -498,7 +498,7 @@ func (t *FSTree) GetRange(ctx context.Context, prm common.GetRangePrm) (common.G
|
||||||
to := from + prm.Range.GetLength()
|
to := from + prm.Range.GetLength()
|
||||||
|
|
||||||
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
||||||
return common.GetRangeRes{}, logicerr.Wrap(apistatus.ObjectOutOfRange{})
|
return common.GetRangeRes{}, logicerr.Wrap(new(apistatus.ObjectOutOfRange))
|
||||||
}
|
}
|
||||||
|
|
||||||
success = true
|
success = true
|
||||||
|
|
|
@ -3,12 +3,12 @@ package blobstor
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
@ -39,12 +39,12 @@ func (b *BlobStor) Get(ctx context.Context, prm common.GetPrm) (res common.GetRe
|
||||||
if prm.StorageID == nil {
|
if prm.StorageID == nil {
|
||||||
for i := range b.storage {
|
for i := range b.storage {
|
||||||
res, err = b.storage[i].Storage.Get(ctx, prm)
|
res, err = b.storage[i].Storage.Get(ctx, prm)
|
||||||
if err == nil || !errors.As(err, new(apistatus.ObjectNotFound)) {
|
if err == nil || !client.IsErrObjectNotFound(err) {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.GetRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.GetRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
if len(prm.StorageID) == 0 {
|
if len(prm.StorageID) == 0 {
|
||||||
res, err = b.storage[len(b.storage)-1].Storage.Get(ctx, prm)
|
res, err = b.storage[len(b.storage)-1].Storage.Get(ctx, prm)
|
||||||
|
|
|
@ -3,13 +3,13 @@ package blobstor
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
@ -41,12 +41,12 @@ func (b *BlobStor) GetRange(ctx context.Context, prm common.GetRangePrm) (res co
|
||||||
if prm.StorageID == nil {
|
if prm.StorageID == nil {
|
||||||
for i := range b.storage {
|
for i := range b.storage {
|
||||||
res, err = b.storage[i].Storage.GetRange(ctx, prm)
|
res, err = b.storage[i].Storage.GetRange(ctx, prm)
|
||||||
if err == nil || !errors.As(err, new(apistatus.ObjectNotFound)) {
|
if err == nil || !client.IsErrObjectNotFound(err) {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.GetRangeRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.GetRangeRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
if len(prm.StorageID) == 0 {
|
if len(prm.StorageID) == 0 {
|
||||||
res, err = b.storage[len(b.storage)-1].Storage.GetRange(ctx, prm)
|
res, err = b.storage[len(b.storage)-1].Storage.GetRange(ctx, prm)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -23,7 +23,7 @@ func TestDelete(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
prm.Address = oidtest.Address()
|
prm.Address = oidtest.Address()
|
||||||
|
|
||||||
_, err := s.Delete(context.Background(), prm)
|
_, err := s.Delete(context.Background(), prm)
|
||||||
require.Error(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("with storage ID", func(t *testing.T) {
|
t.Run("with storage ID", func(t *testing.T) {
|
||||||
|
@ -43,12 +43,12 @@ func TestDelete(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
t.Run("get fail", func(t *testing.T) {
|
t.Run("get fail", func(t *testing.T) {
|
||||||
prm := common.GetPrm{Address: oidtest.Address()}
|
prm := common.GetPrm{Address: oidtest.Address()}
|
||||||
_, err := s.Get(context.Background(), prm)
|
_, err := s.Get(context.Background(), prm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
t.Run("getrange fail", func(t *testing.T) {
|
t.Run("getrange fail", func(t *testing.T) {
|
||||||
prm := common.GetRangePrm{Address: oidtest.Address()}
|
prm := common.GetRangePrm{Address: oidtest.Address()}
|
||||||
_, err := s.GetRange(context.Background(), prm)
|
_, err := s.GetRange(context.Background(), prm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
t.Run("without storage ID", func(t *testing.T) {
|
t.Run("without storage ID", func(t *testing.T) {
|
||||||
|
@ -68,7 +68,7 @@ func TestDelete(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = s.Delete(context.Background(), prm)
|
_, err = s.Delete(context.Background(), prm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("non-deleted object is still available", func(t *testing.T) {
|
t.Run("non-deleted object is still available", func(t *testing.T) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -21,7 +21,7 @@ func TestGet(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
t.Run("missing object", func(t *testing.T) {
|
t.Run("missing object", func(t *testing.T) {
|
||||||
gPrm := common.GetPrm{Address: oidtest.Address()}
|
gPrm := common.GetPrm{Address: oidtest.Address()}
|
||||||
_, err := s.Get(context.Background(), gPrm)
|
_, err := s.Get(context.Background(), gPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
for i := range objects {
|
for i := range objects {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -22,7 +23,7 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
t.Run("missing object", func(t *testing.T) {
|
t.Run("missing object", func(t *testing.T) {
|
||||||
gPrm := common.GetRangePrm{Address: oidtest.Address()}
|
gPrm := common.GetRangePrm{Address: oidtest.Address()}
|
||||||
_, err := s.GetRange(context.Background(), gPrm)
|
_, err := s.GetRange(context.Background(), gPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
payload := objects[0].obj.Payload()
|
payload := objects[0].obj.Payload()
|
||||||
|
@ -56,7 +57,7 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
gPrm.Range.SetLength(10)
|
gPrm.Range.SetLength(10)
|
||||||
|
|
||||||
_, err := s.GetRange(context.Background(), gPrm)
|
_, err := s.GetRange(context.Background(), gPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectOutOfRange))
|
require.ErrorAs(t, err, new(*apistatus.ObjectOutOfRange))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("offset + length > len(payload)", func(t *testing.T) {
|
t.Run("offset + length > len(payload)", func(t *testing.T) {
|
||||||
|
@ -64,7 +65,7 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
gPrm.Range.SetLength(uint64(len(payload)))
|
gPrm.Range.SetLength(uint64(len(payload)))
|
||||||
|
|
||||||
_, err := s.GetRange(context.Background(), gPrm)
|
_, err := s.GetRange(context.Background(), gPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectOutOfRange))
|
require.ErrorAs(t, err, new(*apistatus.ObjectOutOfRange))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("length is negative when converted to int64", func(t *testing.T) {
|
t.Run("length is negative when converted to int64", func(t *testing.T) {
|
||||||
|
@ -72,7 +73,7 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
gPrm.Range.SetLength(1 << 63)
|
gPrm.Range.SetLength(1 << 63)
|
||||||
|
|
||||||
_, err := s.GetRange(context.Background(), gPrm)
|
_, err := s.GetRange(context.Background(), gPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectOutOfRange))
|
require.ErrorAs(t, err, new(*apistatus.ObjectOutOfRange))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("offset + length overflow uint64", func(t *testing.T) {
|
t.Run("offset + length overflow uint64", func(t *testing.T) {
|
||||||
|
@ -80,6 +81,6 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
||||||
gPrm.Range.SetLength(math.MaxUint64 - 2)
|
gPrm.Range.SetLength(math.MaxUint64 - 2)
|
||||||
|
|
||||||
_, err := s.GetRange(context.Background(), gPrm)
|
_, err := s.GetRange(context.Background(), gPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectOutOfRange))
|
require.ErrorAs(t, err, new(*apistatus.ObjectOutOfRange))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (s *memstoreImpl) Get(_ context.Context, req common.GetPrm) (common.GetRes,
|
||||||
s.mu.RUnlock()
|
s.mu.RUnlock()
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
return common.GetRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.GetRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decompress the data.
|
// Decompress the data.
|
||||||
|
@ -73,7 +73,7 @@ func (s *memstoreImpl) GetRange(ctx context.Context, req common.GetRangePrm) (co
|
||||||
to := from + req.Range.GetLength()
|
to := from + req.Range.GetLength()
|
||||||
|
|
||||||
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
||||||
return common.GetRangeRes{}, logicerr.Wrap(apistatus.ObjectOutOfRange{})
|
return common.GetRangeRes{}, logicerr.Wrap(new(apistatus.ObjectOutOfRange))
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.GetRangeRes{
|
return common.GetRangeRes{
|
||||||
|
@ -123,7 +123,7 @@ func (s *memstoreImpl) Delete(_ context.Context, req common.DeletePrm) (common.D
|
||||||
return common.DeleteRes{}, nil
|
return common.DeleteRes{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.DeleteRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return common.DeleteRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *memstoreImpl) Iterate(_ context.Context, req common.IteratePrm) (common.IterateRes, error) {
|
func (s *memstoreImpl) Iterate(_ context.Context, req common.IteratePrm) (common.IterateRes, error) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -72,7 +73,6 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) (DeleteRes, e
|
||||||
|
|
||||||
var locked struct {
|
var locked struct {
|
||||||
is bool
|
is bool
|
||||||
err apistatus.ObjectLocked
|
|
||||||
}
|
}
|
||||||
var splitInfo *objectSDK.SplitInfo
|
var splitInfo *objectSDK.SplitInfo
|
||||||
|
|
||||||
|
@ -85,13 +85,13 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) (DeleteRes, e
|
||||||
|
|
||||||
resExists, err := sh.Exists(ctx, existsPrm)
|
resExists, err := sh.Exists(ctx, existsPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if shard.IsErrRemoved(err) || shard.IsErrObjectExpired(err) {
|
if client.IsErrObjectAlreadyRemoved(err) || shard.IsErrObjectExpired(err) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
var splitErr *objectSDK.SplitInfoError
|
var splitErr *objectSDK.SplitInfoError
|
||||||
if !errors.As(err, &splitErr) {
|
if !errors.As(err, &splitErr) {
|
||||||
if !shard.IsErrNotFound(err) {
|
if !client.IsErrObjectNotFound(err) {
|
||||||
e.reportShardError(sh, "could not check object existence", err)
|
e.reportShardError(sh, "could not check object existence", err)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -111,7 +111,8 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) (DeleteRes, e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.reportShardError(sh, "could not inhume object in shard", err)
|
e.reportShardError(sh, "could not inhume object in shard", err)
|
||||||
|
|
||||||
locked.is = errors.As(err, &locked.err)
|
var target *apistatus.ObjectLocked
|
||||||
|
locked.is = errors.As(err, &target)
|
||||||
|
|
||||||
return locked.is
|
return locked.is
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) (DeleteRes, e
|
||||||
})
|
})
|
||||||
|
|
||||||
if locked.is {
|
if locked.is {
|
||||||
return DeleteRes{}, locked.err
|
return DeleteRes{}, new(apistatus.ObjectLocked)
|
||||||
}
|
}
|
||||||
|
|
||||||
if splitInfo != nil {
|
if splitInfo != nil {
|
||||||
|
|
|
@ -65,16 +65,14 @@ func TestDeleteBigObject(t *testing.T) {
|
||||||
}
|
}
|
||||||
require.NoError(t, Put(context.Background(), e, link))
|
require.NoError(t, Put(context.Background(), e, link))
|
||||||
|
|
||||||
var splitErr *objectSDK.SplitInfoError
|
|
||||||
|
|
||||||
addrParent := object.AddressOf(parent)
|
addrParent := object.AddressOf(parent)
|
||||||
checkGetError(t, e, addrParent, &splitErr)
|
checkGetError[*objectSDK.SplitInfoError](t, e, addrParent, true)
|
||||||
|
|
||||||
addrLink := object.AddressOf(link)
|
addrLink := object.AddressOf(link)
|
||||||
checkGetError(t, e, addrLink, nil)
|
checkGetError[error](t, e, addrLink, false)
|
||||||
|
|
||||||
for i := range children {
|
for i := range children {
|
||||||
checkGetError(t, e, object.AddressOf(children[i]), nil)
|
checkGetError[error](t, e, object.AddressOf(children[i]), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
var deletePrm DeletePrm
|
var deletePrm DeletePrm
|
||||||
|
@ -84,20 +82,21 @@ func TestDeleteBigObject(t *testing.T) {
|
||||||
_, err := e.Delete(context.Background(), deletePrm)
|
_, err := e.Delete(context.Background(), deletePrm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
checkGetError(t, e, addrParent, &apistatus.ObjectNotFound{})
|
checkGetError[*apistatus.ObjectNotFound](t, e, addrParent, true)
|
||||||
checkGetError(t, e, addrLink, &apistatus.ObjectNotFound{})
|
checkGetError[*apistatus.ObjectNotFound](t, e, addrLink, true)
|
||||||
for i := range children {
|
for i := range children {
|
||||||
checkGetError(t, e, object.AddressOf(children[i]), &apistatus.ObjectNotFound{})
|
checkGetError[*apistatus.ObjectNotFound](t, e, object.AddressOf(children[i]), true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkGetError(t *testing.T, e *StorageEngine, addr oid.Address, expected any) {
|
func checkGetError[E error](t *testing.T, e *StorageEngine, addr oid.Address, shouldFail bool) {
|
||||||
var getPrm GetPrm
|
var getPrm GetPrm
|
||||||
getPrm.WithAddress(addr)
|
getPrm.WithAddress(addr)
|
||||||
|
|
||||||
_, err := e.Get(context.Background(), getPrm)
|
_, err := e.Get(context.Background(), getPrm)
|
||||||
if expected != nil {
|
if shouldFail {
|
||||||
require.ErrorAs(t, err, expected)
|
var target E
|
||||||
|
require.ErrorAs(t, err, &target)
|
||||||
} else {
|
} else {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -216,7 +215,7 @@ func TestBlobstorFailback(t *testing.T) {
|
||||||
require.Equal(t, objs[i].Payload()[1:11], rngRes.Object().Payload())
|
require.Equal(t, objs[i].Payload()[1:11], rngRes.Object().Payload())
|
||||||
|
|
||||||
_, err = te.ng.GetRange(context.Background(), RngPrm{addr: addr, off: errSmallSize + 10, ln: 1})
|
_, err = te.ng.GetRange(context.Background(), RngPrm{addr: addr, off: errSmallSize + 10, ln: 1})
|
||||||
require.ErrorAs(t, err, &apistatus.ObjectOutOfRange{})
|
require.True(t, shard.IsErrOutOfRange(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
checkShardState(t, te.ng, te.shards[0].id, 2, mode.ReadOnly)
|
checkShardState(t, te.ng, te.shards[0].id, 2, mode.ReadOnly)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -19,7 +20,7 @@ func (e *StorageEngine) exists(ctx context.Context, addr oid.Address) (bool, err
|
||||||
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
|
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
|
||||||
res, err := sh.Exists(ctx, shPrm)
|
res, err := sh.Exists(ctx, shPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if shard.IsErrRemoved(err) {
|
if client.IsErrObjectAlreadyRemoved(err) {
|
||||||
alreadyRemoved = true
|
alreadyRemoved = true
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -34,7 +35,7 @@ func (e *StorageEngine) exists(ctx context.Context, addr oid.Address) (bool, err
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shard.IsErrNotFound(err) {
|
if !client.IsErrObjectNotFound(err) {
|
||||||
e.reportShardError(sh, "could not check existence of object in shard", err)
|
e.reportShardError(sh, "could not check existence of object in shard", err)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -48,9 +49,7 @@ func (e *StorageEngine) exists(ctx context.Context, addr oid.Address) (bool, err
|
||||||
})
|
})
|
||||||
|
|
||||||
if alreadyRemoved {
|
if alreadyRemoved {
|
||||||
var errRemoved apistatus.ObjectAlreadyRemoved
|
return false, new(apistatus.ObjectAlreadyRemoved)
|
||||||
|
|
||||||
return false, errRemoved
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return exists, nil
|
return exists, nil
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -67,7 +68,7 @@ func (e *StorageEngine) get(ctx context.Context, prm GetPrm) (GetRes, error) {
|
||||||
defer elapsed("Get", e.metrics.AddMethodDuration)()
|
defer elapsed("Get", e.metrics.AddMethodDuration)()
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNotFound apistatus.ObjectNotFound
|
errNotFound := new(apistatus.ObjectNotFound)
|
||||||
|
|
||||||
var shPrm shard.GetPrm
|
var shPrm shard.GetPrm
|
||||||
shPrm.SetAddress(prm.addr)
|
shPrm.SetAddress(prm.addr)
|
||||||
|
@ -90,7 +91,7 @@ func (e *StorageEngine) get(ctx context.Context, prm GetPrm) (GetRes, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if it.Object == nil {
|
if it.Object == nil {
|
||||||
if !it.HasDegraded && it.ShardWithMeta.Shard == nil || !shard.IsErrNotFound(it.OutError) {
|
if !it.HasDegraded && it.ShardWithMeta.Shard == nil || !client.IsErrObjectNotFound(it.OutError) {
|
||||||
return GetRes{}, it.OutError
|
return GetRes{}, it.OutError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ func (i *getShardIterator) tryGetWithMeta(ctx context.Context) {
|
||||||
i.MetaError = err
|
i.MetaError = err
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case shard.IsErrNotFound(err):
|
case client.IsErrObjectNotFound(err):
|
||||||
return false // ignore, go to next shard
|
return false // ignore, go to next shard
|
||||||
case errors.As(err, &i.splitInfoErr):
|
case errors.As(err, &i.splitInfoErr):
|
||||||
if i.SplitInfo == nil {
|
if i.SplitInfo == nil {
|
||||||
|
@ -158,7 +159,7 @@ func (i *getShardIterator) tryGetWithMeta(ctx context.Context) {
|
||||||
|
|
||||||
// stop iterating over shards if SplitInfo structure is complete
|
// stop iterating over shards if SplitInfo structure is complete
|
||||||
return withLink && withLast
|
return withLink && withLast
|
||||||
case shard.IsErrRemoved(err):
|
case client.IsErrObjectAlreadyRemoved(err):
|
||||||
i.OutError = err
|
i.OutError = err
|
||||||
return true // stop, return it back
|
return true // stop, return it back
|
||||||
case shard.IsErrObjectExpired(err):
|
case shard.IsErrObjectExpired(err):
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -74,11 +75,9 @@ func (e *StorageEngine) head(ctx context.Context, prm HeadPrm) (HeadRes, error)
|
||||||
var (
|
var (
|
||||||
head *objectSDK.Object
|
head *objectSDK.Object
|
||||||
siErr *objectSDK.SplitInfoError
|
siErr *objectSDK.SplitInfoError
|
||||||
|
|
||||||
errNotFound apistatus.ObjectNotFound
|
|
||||||
|
|
||||||
outSI *objectSDK.SplitInfo
|
outSI *objectSDK.SplitInfo
|
||||||
outError error = errNotFound
|
|
||||||
|
outError error = new(apistatus.ObjectNotFound)
|
||||||
)
|
)
|
||||||
|
|
||||||
var shPrm shard.HeadPrm
|
var shPrm shard.HeadPrm
|
||||||
|
@ -89,7 +88,7 @@ func (e *StorageEngine) head(ctx context.Context, prm HeadPrm) (HeadRes, error)
|
||||||
res, err := sh.Head(ctx, shPrm)
|
res, err := sh.Head(ctx, shPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case shard.IsErrNotFound(err):
|
case client.IsErrObjectNotFound(err):
|
||||||
return false // ignore, go to next shard
|
return false // ignore, go to next shard
|
||||||
case errors.As(err, &siErr):
|
case errors.As(err, &siErr):
|
||||||
if outSI == nil {
|
if outSI == nil {
|
||||||
|
@ -107,16 +106,14 @@ func (e *StorageEngine) head(ctx context.Context, prm HeadPrm) (HeadRes, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
case shard.IsErrRemoved(err):
|
case client.IsErrObjectAlreadyRemoved(err):
|
||||||
outError = err
|
outError = err
|
||||||
|
|
||||||
return true // stop, return it back
|
return true // stop, return it back
|
||||||
case shard.IsErrObjectExpired(err):
|
case shard.IsErrObjectExpired(err):
|
||||||
var notFoundErr apistatus.ObjectNotFound
|
|
||||||
|
|
||||||
// object is found but should not
|
// object is found but should not
|
||||||
// be returned
|
// be returned
|
||||||
outError = notFoundErr
|
outError = new(apistatus.ObjectNotFound)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -94,8 +95,7 @@ func (e *StorageEngine) inhume(ctx context.Context, prm InhumePrm) (InhumeRes, e
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
zap.Stringer("addr", prm.addrs[i]))
|
zap.Stringer("addr", prm.addrs[i]))
|
||||||
} else if locked {
|
} else if locked {
|
||||||
var lockedErr apistatus.ObjectLocked
|
return InhumeRes{}, new(apistatus.ObjectLocked)
|
||||||
return InhumeRes{}, lockedErr
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,6 @@ func (e *StorageEngine) inhume(ctx context.Context, prm InhumePrm) (InhumeRes, e
|
||||||
// Returns ok if object was inhumed during this invocation or before.
|
// Returns ok if object was inhumed during this invocation or before.
|
||||||
func (e *StorageEngine) inhumeAddr(ctx context.Context, addr oid.Address, prm shard.InhumePrm, checkExists bool) (bool, error) {
|
func (e *StorageEngine) inhumeAddr(ctx context.Context, addr oid.Address, prm shard.InhumePrm, checkExists bool) (bool, error) {
|
||||||
root := false
|
root := false
|
||||||
var errLocked apistatus.ObjectLocked
|
|
||||||
var existPrm shard.ExistsPrm
|
var existPrm shard.ExistsPrm
|
||||||
var retErr error
|
var retErr error
|
||||||
var ok bool
|
var ok bool
|
||||||
|
@ -143,7 +142,7 @@ func (e *StorageEngine) inhumeAddr(ctx context.Context, addr oid.Address, prm sh
|
||||||
existPrm.SetAddress(addr)
|
existPrm.SetAddress(addr)
|
||||||
exRes, err := sh.Exists(ctx, existPrm)
|
exRes, err := sh.Exists(ctx, existPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if shard.IsErrRemoved(err) || shard.IsErrObjectExpired(err) {
|
if client.IsErrObjectAlreadyRemoved(err) || shard.IsErrObjectExpired(err) {
|
||||||
// inhumed once - no need to be inhumed again
|
// inhumed once - no need to be inhumed again
|
||||||
ok = true
|
ok = true
|
||||||
return true
|
return true
|
||||||
|
@ -163,9 +162,10 @@ func (e *StorageEngine) inhumeAddr(ctx context.Context, addr oid.Address, prm sh
|
||||||
|
|
||||||
_, err := sh.Inhume(ctx, prm)
|
_, err := sh.Inhume(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var errLocked *apistatus.ObjectLocked
|
||||||
switch {
|
switch {
|
||||||
case errors.As(err, &errLocked):
|
case errors.As(err, &errLocked):
|
||||||
retErr = apistatus.ObjectLocked{}
|
retErr = new(apistatus.ObjectLocked)
|
||||||
return true
|
return true
|
||||||
case errors.Is(err, shard.ErrLockObjectRemoval):
|
case errors.Is(err, shard.ErrLockObjectRemoval):
|
||||||
retErr = meta.ErrLockObjectRemoval
|
retErr = meta.ErrLockObjectRemoval
|
||||||
|
|
|
@ -41,11 +41,11 @@ func (e *StorageEngine) lock(ctx context.Context, idCnr cid.ID, locker oid.ID, l
|
||||||
for i := range locked {
|
for i := range locked {
|
||||||
switch e.lockSingle(ctx, idCnr, locker, locked[i], true) {
|
switch e.lockSingle(ctx, idCnr, locker, locked[i], true) {
|
||||||
case 1:
|
case 1:
|
||||||
return logicerr.Wrap(apistatus.LockNonRegularObject{})
|
return logicerr.Wrap(new(apistatus.LockNonRegularObject))
|
||||||
case 0:
|
case 0:
|
||||||
switch e.lockSingle(ctx, idCnr, locker, locked[i], false) {
|
switch e.lockSingle(ctx, idCnr, locker, locked[i], false) {
|
||||||
case 1:
|
case 1:
|
||||||
return logicerr.Wrap(apistatus.LockNonRegularObject{})
|
return logicerr.Wrap(new(apistatus.LockNonRegularObject))
|
||||||
case 0:
|
case 0:
|
||||||
return logicerr.Wrap(errLockFailed)
|
return logicerr.Wrap(errLockFailed)
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ func (e *StorageEngine) lock(ctx context.Context, idCnr cid.ID, locker oid.ID, l
|
||||||
func (e *StorageEngine) lockSingle(ctx context.Context, idCnr cid.ID, locker, locked oid.ID, checkExists bool) (status uint8) {
|
func (e *StorageEngine) lockSingle(ctx context.Context, idCnr cid.ID, locker, locked oid.ID, checkExists bool) (status uint8) {
|
||||||
// code is pretty similar to inhumeAddr, maybe unify?
|
// code is pretty similar to inhumeAddr, maybe unify?
|
||||||
root := false
|
root := false
|
||||||
var errIrregular apistatus.LockNonRegularObject
|
|
||||||
|
|
||||||
var addrLocked oid.Address
|
var addrLocked oid.Address
|
||||||
addrLocked.SetContainer(idCnr)
|
addrLocked.SetContainer(idCnr)
|
||||||
|
@ -105,6 +104,7 @@ func (e *StorageEngine) lockSingle(ctx context.Context, idCnr cid.ID, locker, lo
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.reportShardError(sh, "could not lock object in shard", err)
|
e.reportShardError(sh, "could not lock object in shard", err)
|
||||||
|
|
||||||
|
var errIrregular *apistatus.LockNonRegularObject
|
||||||
if errors.As(err, &errIrregular) {
|
if errors.As(err, &errIrregular) {
|
||||||
status = 1
|
status = 1
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -119,8 +119,9 @@ func TestLockUserScenario(t *testing.T) {
|
||||||
var inhumePrm InhumePrm
|
var inhumePrm InhumePrm
|
||||||
inhumePrm.WithTarget(tombAddr, objAddr)
|
inhumePrm.WithTarget(tombAddr, objAddr)
|
||||||
|
|
||||||
|
var objLockedErr *apistatus.ObjectLocked
|
||||||
_, err = e.Inhume(context.Background(), inhumePrm)
|
_, err = e.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
// 4.
|
// 4.
|
||||||
tombObj.SetType(objectSDK.TypeTombstone)
|
tombObj.SetType(objectSDK.TypeTombstone)
|
||||||
|
@ -208,8 +209,9 @@ func TestLockExpiration(t *testing.T) {
|
||||||
var inhumePrm InhumePrm
|
var inhumePrm InhumePrm
|
||||||
inhumePrm.WithTarget(oidtest.Address(), objectcore.AddressOf(obj))
|
inhumePrm.WithTarget(oidtest.Address(), objectcore.AddressOf(obj))
|
||||||
|
|
||||||
|
var objLockedErr *apistatus.ObjectLocked
|
||||||
_, err = e.Inhume(context.Background(), inhumePrm)
|
_, err = e.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
e.HandleNewEpoch(lockerExpiresAfter + 1)
|
e.HandleNewEpoch(lockerExpiresAfter + 1)
|
||||||
|
@ -281,13 +283,14 @@ func TestLockForceRemoval(t *testing.T) {
|
||||||
var inhumePrm InhumePrm
|
var inhumePrm InhumePrm
|
||||||
inhumePrm.MarkAsGarbage(objectcore.AddressOf(obj))
|
inhumePrm.MarkAsGarbage(objectcore.AddressOf(obj))
|
||||||
|
|
||||||
|
var objLockedErr *apistatus.ObjectLocked
|
||||||
_, err = e.Inhume(context.Background(), inhumePrm)
|
_, err = e.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
inhumePrm.WithTarget(oidtest.Address(), objectcore.AddressOf(obj))
|
inhumePrm.WithTarget(oidtest.Address(), objectcore.AddressOf(obj))
|
||||||
|
|
||||||
_, err = e.Inhume(context.Background(), inhumePrm)
|
_, err = e.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
// 4.
|
// 4.
|
||||||
var deletePrm DeletePrm
|
var deletePrm DeletePrm
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -83,14 +84,12 @@ func (e *StorageEngine) getRange(ctx context.Context, prm RngPrm) (RngRes, error
|
||||||
defer elapsed("GetRange", e.metrics.AddMethodDuration)()
|
defer elapsed("GetRange", e.metrics.AddMethodDuration)()
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNotFound apistatus.ObjectNotFound
|
|
||||||
|
|
||||||
var shPrm shard.RngPrm
|
var shPrm shard.RngPrm
|
||||||
shPrm.SetAddress(prm.addr)
|
shPrm.SetAddress(prm.addr)
|
||||||
shPrm.SetRange(prm.off, prm.ln)
|
shPrm.SetRange(prm.off, prm.ln)
|
||||||
|
|
||||||
it := &getRangeShardIterator{
|
it := &getRangeShardIterator{
|
||||||
OutError: errNotFound,
|
OutError: new(apistatus.ObjectNotFound),
|
||||||
ShardPrm: shPrm,
|
ShardPrm: shPrm,
|
||||||
Address: prm.addr,
|
Address: prm.addr,
|
||||||
Engine: e,
|
Engine: e,
|
||||||
|
@ -105,7 +104,7 @@ func (e *StorageEngine) getRange(ctx context.Context, prm RngPrm) (RngRes, error
|
||||||
if it.Object == nil {
|
if it.Object == nil {
|
||||||
// If any shard is in a degraded mode, we should assume that metabase could store
|
// If any shard is in a degraded mode, we should assume that metabase could store
|
||||||
// info about some object.
|
// info about some object.
|
||||||
if it.ShardWithMeta.Shard == nil && !it.HasDegraded || !shard.IsErrNotFound(it.OutError) {
|
if it.ShardWithMeta.Shard == nil && !it.HasDegraded || !client.IsErrObjectNotFound(it.OutError) {
|
||||||
return RngRes{}, it.OutError
|
return RngRes{}, it.OutError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +170,7 @@ func (i *getRangeShardIterator) tryGetWithMeta(ctx context.Context) {
|
||||||
i.MetaError = err
|
i.MetaError = err
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case shard.IsErrNotFound(err):
|
case client.IsErrObjectNotFound(err):
|
||||||
return false // ignore, go to next shard
|
return false // ignore, go to next shard
|
||||||
case errors.As(err, &i.SplitInfoError):
|
case errors.As(err, &i.SplitInfoError):
|
||||||
if i.SplitInfo == nil {
|
if i.SplitInfo == nil {
|
||||||
|
@ -186,7 +185,7 @@ func (i *getRangeShardIterator) tryGetWithMeta(ctx context.Context) {
|
||||||
// stop iterating over shards if SplitInfo structure is complete
|
// stop iterating over shards if SplitInfo structure is complete
|
||||||
return withLink && withLast
|
return withLink && withLast
|
||||||
case
|
case
|
||||||
shard.IsErrRemoved(err),
|
client.IsErrObjectAlreadyRemoved(err),
|
||||||
shard.IsErrOutOfRange(err):
|
shard.IsErrOutOfRange(err):
|
||||||
i.OutError = err
|
i.OutError = err
|
||||||
|
|
||||||
|
@ -212,9 +211,7 @@ func (i *getRangeShardIterator) tryGetFromBlobstor(ctx context.Context) {
|
||||||
|
|
||||||
res, err := sh.GetRange(ctx, i.ShardPrm)
|
res, err := sh.GetRange(ctx, i.ShardPrm)
|
||||||
if shard.IsErrOutOfRange(err) {
|
if shard.IsErrOutOfRange(err) {
|
||||||
var errOutOfRange apistatus.ObjectOutOfRange
|
i.OutError = new(apistatus.ObjectOutOfRange)
|
||||||
|
|
||||||
i.OutError = errOutOfRange
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
i.Object = res.Object()
|
i.Object = res.Object()
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -43,7 +44,7 @@ func TestReset(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assertExists(addr, true, nil)
|
assertExists(addr, true, nil)
|
||||||
assertExists(addrToInhume, false, meta.IsErrRemoved)
|
assertExists(addrToInhume, false, client.IsErrObjectAlreadyRemoved)
|
||||||
|
|
||||||
err = db.Reset()
|
err = db.Reset()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log"
|
storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
|
@ -204,9 +204,8 @@ func (db *DB) delete(tx *bbolt.Tx, addr oid.Address, refCounter referenceCounter
|
||||||
obj, err := db.get(tx, addr, key, false, true, currEpoch)
|
obj, err := db.get(tx, addr, key, false, true, currEpoch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var siErr *objectSDK.SplitInfoError
|
var siErr *objectSDK.SplitInfoError
|
||||||
var notFoundErr apistatus.ObjectNotFound
|
|
||||||
|
|
||||||
if errors.As(err, ¬FoundErr) || errors.As(err, &siErr) {
|
if client.IsErrObjectNotFound(err) || errors.As(err, &siErr) {
|
||||||
return false, false, 0, nil
|
return false, false, 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -68,11 +68,11 @@ func TestDB_Delete(t *testing.T) {
|
||||||
// check if they marked as already removed
|
// check if they marked as already removed
|
||||||
|
|
||||||
ok, err := metaExists(db, object.AddressOf(child))
|
ok, err := metaExists(db, object.AddressOf(child))
|
||||||
require.ErrorAs(t, err, &apistatus.ObjectAlreadyRemoved{})
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
require.False(t, ok)
|
require.False(t, ok)
|
||||||
|
|
||||||
ok, err = metaExists(db, object.AddressOf(parent))
|
ok, err = metaExists(db, object.AddressOf(parent))
|
||||||
require.ErrorAs(t, err, &apistatus.ObjectAlreadyRemoved{})
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
require.False(t, ok)
|
require.False(t, ok)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
package meta
|
package meta
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrObjectIsExpired is returned when the requested object's
|
// ErrObjectIsExpired is returned when the requested object's
|
||||||
// epoch is less than the current one. Such objects are considered
|
// epoch is less than the current one. Such objects are considered
|
||||||
// as removed and should not be returned from the Storage Engine.
|
// as removed and should not be returned from the Storage Engine.
|
||||||
var ErrObjectIsExpired = logicerr.New("object is expired")
|
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 {
|
|
||||||
return errors.As(err, new(apistatus.ObjectAlreadyRemoved))
|
|
||||||
}
|
|
||||||
|
|
|
@ -82,9 +82,9 @@ func (db *DB) exists(tx *bbolt.Tx, addr oid.Address, currEpoch uint64) (exists b
|
||||||
// check graveyard and object expiration first
|
// check graveyard and object expiration first
|
||||||
switch objectStatus(tx, addr, currEpoch) {
|
switch objectStatus(tx, addr, currEpoch) {
|
||||||
case 1:
|
case 1:
|
||||||
return false, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return false, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
case 2:
|
case 2:
|
||||||
return false, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
|
return false, logicerr.Wrap(new(apistatus.ObjectAlreadyRemoved))
|
||||||
case 3:
|
case 3:
|
||||||
return false, ErrObjectIsExpired
|
return false, ErrObjectIsExpired
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||||
|
@ -40,7 +40,7 @@ func TestDB_Exists(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
exists, err := metaExists(db, object.AddressOf(regular))
|
exists, err := metaExists(db, object.AddressOf(regular))
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
require.False(t, exists)
|
require.False(t, exists)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -91,9 +91,9 @@ func (db *DB) get(tx *bbolt.Tx, addr oid.Address, key []byte, checkStatus, raw b
|
||||||
if checkStatus {
|
if checkStatus {
|
||||||
switch objectStatus(tx, addr, currEpoch) {
|
switch objectStatus(tx, addr, currEpoch) {
|
||||||
case 1:
|
case 1:
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
case 2:
|
case 2:
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
|
return nil, logicerr.Wrap(new(apistatus.ObjectAlreadyRemoved))
|
||||||
case 3:
|
case 3:
|
||||||
return nil, ErrObjectIsExpired
|
return nil, ErrObjectIsExpired
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ func getVirtualObject(tx *bbolt.Tx, cnr cid.ID, key []byte, raw bool) (*objectSD
|
||||||
bucketName := make([]byte, bucketKeySize)
|
bucketName := make([]byte, bucketKeySize)
|
||||||
parentBucket := tx.Bucket(parentBucketName(cnr, bucketName))
|
parentBucket := tx.Bucket(parentBucketName(cnr, bucketName))
|
||||||
if parentBucket == nil {
|
if parentBucket == nil {
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
relativeLst, err := decodeList(parentBucket.Get(key))
|
relativeLst, err := decodeList(parentBucket.Get(key))
|
||||||
|
@ -152,7 +152,7 @@ func getVirtualObject(tx *bbolt.Tx, cnr cid.ID, key []byte, raw bool) (*objectSD
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(relativeLst) == 0 { // this should never happen though
|
if len(relativeLst) == 0 { // this should never happen though
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// pick last item, for now there is not difference which address to pick
|
// pick last item, for now there is not difference which address to pick
|
||||||
|
@ -171,7 +171,7 @@ func getVirtualObject(tx *bbolt.Tx, cnr cid.ID, key []byte, raw bool) (*objectSD
|
||||||
par := child.Parent()
|
par := child.Parent()
|
||||||
|
|
||||||
if par == nil { // this should never happen though
|
if par == nil { // this should never happen though
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
return par, nil
|
return par, nil
|
||||||
|
@ -183,5 +183,5 @@ func getSplitInfoError(tx *bbolt.Tx, cnr cid.ID, key []byte) error {
|
||||||
return logicerr.Wrap(objectSDK.NewSplitInfoError(splitInfo))
|
return logicerr.Wrap(objectSDK.NewSplitInfoError(splitInfo))
|
||||||
}
|
}
|
||||||
|
|
||||||
return logicerr.Wrap(apistatus.ObjectNotFound{})
|
return logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -114,7 +114,7 @@ func TestDB_Get(t *testing.T) {
|
||||||
|
|
||||||
require.NoError(t, metaInhume(db, obj, ts))
|
require.NoError(t, metaInhume(db, obj, ts))
|
||||||
_, err := metaGet(db, obj, false)
|
_, err := metaGet(db, obj, false)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
|
|
||||||
obj = oidtest.Address()
|
obj = oidtest.Address()
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ func TestDB_Get(t *testing.T) {
|
||||||
_, err = db.Inhume(context.Background(), prm)
|
_, err = db.Inhume(context.Background(), prm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, err = metaGet(db, obj, false)
|
_, err = metaGet(db, obj, false)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("expired object", func(t *testing.T) {
|
t.Run("expired object", func(t *testing.T) {
|
||||||
|
|
|
@ -166,7 +166,7 @@ func (db *DB) inhumeTx(tx *bbolt.Tx, epoch uint64, prm InhumePrm, res *InhumeRes
|
||||||
|
|
||||||
// prevent locked objects to be inhumed
|
// prevent locked objects to be inhumed
|
||||||
if !prm.forceRemoval && objectLocked(tx, cnr, id) {
|
if !prm.forceRemoval && objectLocked(tx, cnr, id) {
|
||||||
return apistatus.ObjectLocked{}
|
return new(apistatus.ObjectLocked)
|
||||||
}
|
}
|
||||||
|
|
||||||
var lockWasChecked bool
|
var lockWasChecked bool
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||||
|
@ -28,10 +29,10 @@ func TestDB_Inhume(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = metaExists(db, object.AddressOf(raw))
|
_, err = metaExists(db, object.AddressOf(raw))
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
|
|
||||||
_, err = metaGet(db, object.AddressOf(raw), false)
|
_, err = metaGet(db, object.AddressOf(raw), false)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInhumeTombOnTomb(t *testing.T) {
|
func TestInhumeTombOnTomb(t *testing.T) {
|
||||||
|
@ -58,7 +59,7 @@ func TestInhumeTombOnTomb(t *testing.T) {
|
||||||
|
|
||||||
// addr1 should become inhumed {addr1:addr2}
|
// addr1 should become inhumed {addr1:addr2}
|
||||||
_, err = db.Exists(context.Background(), existsPrm)
|
_, err = db.Exists(context.Background(), existsPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
|
|
||||||
inhumePrm.SetAddresses(addr3)
|
inhumePrm.SetAddresses(addr3)
|
||||||
inhumePrm.SetTombstoneAddress(addr1)
|
inhumePrm.SetTombstoneAddress(addr1)
|
||||||
|
@ -72,13 +73,13 @@ func TestInhumeTombOnTomb(t *testing.T) {
|
||||||
// NOT ObjectAlreadyRemoved since that record has been removed
|
// NOT ObjectAlreadyRemoved since that record has been removed
|
||||||
// from graveyard but addr1 is still marked with GC
|
// from graveyard but addr1 is still marked with GC
|
||||||
_, err = db.Exists(context.Background(), existsPrm)
|
_, err = db.Exists(context.Background(), existsPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
existsPrm.SetAddress(addr3)
|
existsPrm.SetAddress(addr3)
|
||||||
|
|
||||||
// addr3 should be inhumed {addr3: addr1}
|
// addr3 should be inhumed {addr3: addr1}
|
||||||
_, err = db.Exists(context.Background(), existsPrm)
|
_, err = db.Exists(context.Background(), existsPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
|
|
||||||
inhumePrm.SetAddresses(addr1)
|
inhumePrm.SetAddresses(addr1)
|
||||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||||
|
@ -93,7 +94,7 @@ func TestInhumeTombOnTomb(t *testing.T) {
|
||||||
// (tomb can not be inhumed) but should be kept as object
|
// (tomb can not be inhumed) but should be kept as object
|
||||||
// with GC mark
|
// with GC mark
|
||||||
_, err = db.Exists(context.Background(), existsPrm)
|
_, err = db.Exists(context.Background(), existsPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInhumeLocked(t *testing.T) {
|
func TestInhumeLocked(t *testing.T) {
|
||||||
|
@ -109,7 +110,7 @@ func TestInhumeLocked(t *testing.T) {
|
||||||
|
|
||||||
_, err = db.Inhume(context.Background(), prm)
|
_, err = db.Inhume(context.Background(), prm)
|
||||||
|
|
||||||
var e apistatus.ObjectLocked
|
var e *apistatus.ObjectLocked
|
||||||
require.ErrorAs(t, err, &e)
|
require.ErrorAs(t, err, &e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (db *DB) lockInternal(locked []oid.ID, cnr cid.ID, locker oid.ID) error {
|
||||||
|
|
||||||
return metaerr.Wrap(db.boltDB.Update(func(tx *bbolt.Tx) error {
|
return metaerr.Wrap(db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||||
if firstIrregularObjectType(tx, cnr, bucketKeysLocked...) != objectSDK.TypeRegular {
|
if firstIrregularObjectType(tx, cnr, bucketKeysLocked...) != objectSDK.TypeRegular {
|
||||||
return logicerr.Wrap(apistatus.LockNonRegularObject{})
|
return logicerr.Wrap(new(apistatus.LockNonRegularObject))
|
||||||
}
|
}
|
||||||
|
|
||||||
bucketLocked := tx.Bucket(bucketNameLocked)
|
bucketLocked := tx.Bucket(bucketNameLocked)
|
||||||
|
|
|
@ -41,7 +41,7 @@ func TestDB_Lock(t *testing.T) {
|
||||||
err := metaPut(db, obj, nil)
|
err := metaPut(db, obj, nil)
|
||||||
require.NoError(t, err, typ)
|
require.NoError(t, err, typ)
|
||||||
|
|
||||||
var e apistatus.LockNonRegularObject
|
var e *apistatus.LockNonRegularObject
|
||||||
|
|
||||||
id, _ := obj.ID()
|
id, _ := obj.ID()
|
||||||
|
|
||||||
|
@ -66,13 +66,15 @@ func TestDB_Lock(t *testing.T) {
|
||||||
|
|
||||||
// check locking relation
|
// check locking relation
|
||||||
|
|
||||||
|
var objLockedErr *apistatus.ObjectLocked
|
||||||
|
|
||||||
inhumePrm.SetAddresses(objAddr)
|
inhumePrm.SetAddresses(objAddr)
|
||||||
_, err := db.Inhume(context.Background(), inhumePrm)
|
_, err := db.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
// try to remove lock object
|
// try to remove lock object
|
||||||
inhumePrm.SetAddresses(lockAddr)
|
inhumePrm.SetAddresses(lockAddr)
|
||||||
|
@ -84,11 +86,11 @@ func TestDB_Lock(t *testing.T) {
|
||||||
|
|
||||||
inhumePrm.SetAddresses(objAddr)
|
inhumePrm.SetAddresses(objAddr)
|
||||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("lock-unlock scenario", func(t *testing.T) {
|
t.Run("lock-unlock scenario", func(t *testing.T) {
|
||||||
|
@ -97,9 +99,11 @@ func TestDB_Lock(t *testing.T) {
|
||||||
objAddr := objectcore.AddressOf(objs[0])
|
objAddr := objectcore.AddressOf(objs[0])
|
||||||
lockAddr := objectcore.AddressOf(lockObj)
|
lockAddr := objectcore.AddressOf(lockObj)
|
||||||
|
|
||||||
|
var objLockedErr *apistatus.ObjectLocked
|
||||||
|
|
||||||
// try to inhume locked object using tombstone
|
// try to inhume locked object using tombstone
|
||||||
err := metaInhume(db, objAddr, lockAddr)
|
err := metaInhume(db, objAddr, lockAddr)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
// free locked object
|
// free locked object
|
||||||
var inhumePrm meta.InhumePrm
|
var inhumePrm meta.InhumePrm
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -195,7 +196,7 @@ func (s *Shard) refillMetabase(ctx context.Context) error {
|
||||||
mPrm.SetStorageID(descriptor)
|
mPrm.SetStorageID(descriptor)
|
||||||
|
|
||||||
_, err = s.metaBase.Put(ctx, mPrm)
|
_, err = s.metaBase.Put(ctx, mPrm)
|
||||||
if err != nil && !meta.IsErrRemoved(err) && !errors.Is(err, meta.ErrObjectIsExpired) {
|
if err != nil && !client.IsErrObjectAlreadyRemoved(err) && !errors.Is(err, meta.ErrObjectIsExpired) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
writecacheconfig "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/config"
|
writecacheconfig "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/config"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/writecachebbolt"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/writecachebbolt"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
|
@ -170,7 +171,7 @@ func TestRefillMetabaseCorrupted(t *testing.T) {
|
||||||
var getPrm GetPrm
|
var getPrm GetPrm
|
||||||
getPrm.SetAddress(addr)
|
getPrm.SetAddress(addr)
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
require.NoError(t, sh.Close())
|
require.NoError(t, sh.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +298,7 @@ func TestRefillMetabase(t *testing.T) {
|
||||||
res, err := sh.Head(context.Background(), headPrm)
|
res, err := sh.Head(context.Background(), headPrm)
|
||||||
|
|
||||||
if expObj == nil {
|
if expObj == nil {
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,9 +323,9 @@ func TestRefillMetabase(t *testing.T) {
|
||||||
_, err := sh.Head(context.Background(), headPrm)
|
_, err := sh.Head(context.Background(), headPrm)
|
||||||
|
|
||||||
if exists {
|
if exists {
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
} else {
|
} else {
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,9 +340,9 @@ func TestRefillMetabase(t *testing.T) {
|
||||||
var prm InhumePrm
|
var prm InhumePrm
|
||||||
prm.MarkAsGarbage(addr)
|
prm.MarkAsGarbage(addr)
|
||||||
|
|
||||||
|
var target *apistatus.ObjectLocked
|
||||||
_, err := sh.Inhume(context.Background(), prm)
|
_, err := sh.Inhume(context.Background(), prm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked),
|
require.ErrorAs(t, err, &target, "object %s should be locked", locked[i])
|
||||||
"object %s should be locked", locked[i])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
@ -79,7 +80,7 @@ func (s *Shard) delete(ctx context.Context, prm DeletePrm) (DeleteRes, error) {
|
||||||
func (s *Shard) deleteObjectFromWriteCacheSafe(ctx context.Context, addr oid.Address) {
|
func (s *Shard) deleteObjectFromWriteCacheSafe(ctx context.Context, addr oid.Address) {
|
||||||
if s.hasWriteCache() {
|
if s.hasWriteCache() {
|
||||||
err := s.writeCache.Delete(ctx, addr)
|
err := s.writeCache.Delete(ctx, addr)
|
||||||
if err != nil && !IsErrNotFound(err) && !errors.Is(err, writecache.ErrReadOnly) {
|
if err != nil && !client.IsErrObjectNotFound(err) && !errors.Is(err, writecache.ErrReadOnly) {
|
||||||
s.log.Warn(logs.ShardCantDeleteObjectFromWriteCache, zap.Error(err))
|
s.log.Warn(logs.ShardCantDeleteObjectFromWriteCache, zap.Error(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -57,7 +57,7 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("small object", func(t *testing.T) {
|
t.Run("small object", func(t *testing.T) {
|
||||||
|
@ -81,6 +81,6 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,11 @@ import (
|
||||||
|
|
||||||
var ErrShardDisabled = logicerr.New("shard disabled")
|
var ErrShardDisabled = logicerr.New("shard disabled")
|
||||||
|
|
||||||
// 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))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsErrOutOfRange checks if an error returned by Shard GetRange method
|
// IsErrOutOfRange checks if an error returned by Shard GetRange method
|
||||||
// corresponds to exceeding the object bounds.
|
// corresponds to exceeding the object bounds.
|
||||||
func IsErrOutOfRange(err error) bool {
|
func IsErrOutOfRange(err error) bool {
|
||||||
return errors.As(err, new(apistatus.ObjectOutOfRange))
|
var target *apistatus.ObjectOutOfRange
|
||||||
|
return errors.As(err, &target)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsErrObjectExpired checks if an error returned by Shard corresponds to
|
// IsErrObjectExpired checks if an error returned by Shard corresponds to
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -109,7 +110,7 @@ func Test_ObjectNotFoundIfNotDeletedFromMetabase(t *testing.T) {
|
||||||
require.NoError(t, err, "failed to inhume")
|
require.NoError(t, err, "failed to inhume")
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
require.Error(t, err, "get returned error")
|
require.Error(t, err, "get returned error")
|
||||||
require.True(t, IsErrNotFound(err), "invalid error type")
|
require.True(t, client.IsErrObjectNotFound(err), "invalid error type")
|
||||||
|
|
||||||
//storageID
|
//storageID
|
||||||
var metaStIDPrm meta.StorageIDPrm
|
var metaStIDPrm meta.StorageIDPrm
|
||||||
|
@ -140,5 +141,5 @@ func Test_ObjectNotFoundIfNotDeletedFromMetabase(t *testing.T) {
|
||||||
//get should return object not found
|
//get should return object not found
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
require.Error(t, err, "get returned no error")
|
require.Error(t, err, "get returned no error")
|
||||||
require.True(t, IsErrNotFound(err), "invalid error type")
|
require.True(t, client.IsErrObjectNotFound(err), "invalid error type")
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
writecacheconfig "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/config"
|
writecacheconfig "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache/config"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -74,7 +75,7 @@ func Test_GCDropsLockedExpiredSimpleObject(t *testing.T) {
|
||||||
getPrm.SetAddress(objectCore.AddressOf(obj))
|
getPrm.SetAddress(objectCore.AddressOf(obj))
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
return shard.IsErrNotFound(err)
|
return client.IsErrObjectNotFound(err)
|
||||||
}, 3*time.Second, 1*time.Second, "expired object must be deleted")
|
}, 3*time.Second, 1*time.Second, "expired object must be deleted")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +172,6 @@ func Test_GCDropsLockedExpiredComplexObject(t *testing.T) {
|
||||||
|
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
return shard.IsErrNotFound(err)
|
return client.IsErrObjectNotFound(err)
|
||||||
}, 3*time.Second, 1*time.Second, "expired complex object must be deleted on epoch after lock expires")
|
}, 3*time.Second, 1*time.Second, "expired complex object must be deleted on epoch after lock expires")
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -129,7 +130,7 @@ func (s *Shard) fetchObjectData(ctx context.Context, addr oid.Address, skipMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
if !mRes.Exists() {
|
if !mRes.Exists() {
|
||||||
return nil, false, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return nil, false, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s.log.Warn(logs.ShardFetchingObjectWithoutMeta, zap.Stringer("addr", addr))
|
s.log.Warn(logs.ShardFetchingObjectWithoutMeta, zap.Stringer("addr", addr))
|
||||||
|
@ -140,7 +141,7 @@ func (s *Shard) fetchObjectData(ctx context.Context, addr oid.Address, skipMeta
|
||||||
if err == nil || IsErrOutOfRange(err) {
|
if err == nil || IsErrOutOfRange(err) {
|
||||||
return res, false, err
|
return res, false, err
|
||||||
}
|
}
|
||||||
if IsErrNotFound(err) {
|
if client.IsErrObjectNotFound(err) {
|
||||||
s.log.Debug(logs.ShardObjectIsMissingInWritecache,
|
s.log.Debug(logs.ShardObjectIsMissingInWritecache,
|
||||||
zap.Stringer("addr", addr),
|
zap.Stringer("addr", addr),
|
||||||
zap.Bool("skip_meta", skipMeta))
|
zap.Bool("skip_meta", skipMeta))
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||||
|
@ -119,10 +120,10 @@ func testGet(t *testing.T, sh *shard.Shard, getPrm shard.GetPrm, hasWriteCache b
|
||||||
res, err := sh.Get(context.Background(), getPrm)
|
res, err := sh.Get(context.Background(), getPrm)
|
||||||
if hasWriteCache {
|
if hasWriteCache {
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
if shard.IsErrNotFound(err) {
|
if client.IsErrObjectNotFound(err) {
|
||||||
res, err = sh.Get(context.Background(), getPrm)
|
res, err = sh.Get(context.Background(), getPrm)
|
||||||
}
|
}
|
||||||
return !shard.IsErrNotFound(err)
|
return !client.IsErrObjectNotFound(err)
|
||||||
}, time.Second, time.Millisecond*100)
|
}, time.Second, time.Millisecond*100)
|
||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -90,10 +91,10 @@ func testHead(t *testing.T, sh *shard.Shard, headPrm shard.HeadPrm, hasWriteCach
|
||||||
res, err := sh.Head(context.Background(), headPrm)
|
res, err := sh.Head(context.Background(), headPrm)
|
||||||
if hasWriteCache {
|
if hasWriteCache {
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
if shard.IsErrNotFound(err) {
|
if client.IsErrObjectNotFound(err) {
|
||||||
res, err = sh.Head(context.Background(), headPrm)
|
res, err = sh.Head(context.Background(), headPrm)
|
||||||
}
|
}
|
||||||
return !shard.IsErrNotFound(err)
|
return !client.IsErrObjectNotFound(err)
|
||||||
}, time.Second, time.Millisecond*100)
|
}, time.Second, time.Millisecond*100)
|
||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -56,5 +56,5 @@ func testShardInhume(t *testing.T, hasWriteCache bool) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
|
@ -96,12 +97,14 @@ func TestShard_Lock(t *testing.T) {
|
||||||
var inhumePrm shard.InhumePrm
|
var inhumePrm shard.InhumePrm
|
||||||
inhumePrm.SetTarget(objectcore.AddressOf(ts), objectcore.AddressOf(obj))
|
inhumePrm.SetTarget(objectcore.AddressOf(ts), objectcore.AddressOf(obj))
|
||||||
|
|
||||||
|
var objLockedErr *apistatus.ObjectLocked
|
||||||
|
|
||||||
_, err = sh.Inhume(context.Background(), inhumePrm)
|
_, err = sh.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
|
|
||||||
inhumePrm.MarkAsGarbage(objectcore.AddressOf(obj))
|
inhumePrm.MarkAsGarbage(objectcore.AddressOf(obj))
|
||||||
_, err = sh.Inhume(context.Background(), inhumePrm)
|
_, err = sh.Inhume(context.Background(), inhumePrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
require.ErrorAs(t, err, &objLockedErr)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("inhuming lock objects", func(t *testing.T) {
|
t.Run("inhuming lock objects", func(t *testing.T) {
|
||||||
|
@ -141,7 +144,7 @@ func TestShard_Lock(t *testing.T) {
|
||||||
getPrm.SetAddress(objectcore.AddressOf(obj))
|
getPrm.SetAddress(objectcore.AddressOf(obj))
|
||||||
|
|
||||||
_, err = sh.Get(context.Background(), getPrm)
|
_, err = sh.Get(context.Background(), getPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, client.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ func (s *Shard) GetRange(ctx context.Context, prm RngPrm) (RngRes, error) {
|
||||||
from := prm.off
|
from := prm.off
|
||||||
to := from + prm.ln
|
to := from + prm.ln
|
||||||
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectOutOfRange{})
|
return nil, logicerr.Wrap(new(apistatus.ObjectOutOfRange))
|
||||||
}
|
}
|
||||||
|
|
||||||
obj := objectSDK.New()
|
obj := objectSDK.New()
|
||||||
|
|
|
@ -119,7 +119,8 @@ func testShardGetRange(t *testing.T, hasWriteCache bool) {
|
||||||
|
|
||||||
res, err := sh.GetRange(context.Background(), rngPrm)
|
res, err := sh.GetRange(context.Background(), rngPrm)
|
||||||
if tc.hasErr {
|
if tc.hasErr {
|
||||||
require.ErrorAs(t, err, &apistatus.ObjectOutOfRange{})
|
var target *apistatus.ObjectOutOfRange
|
||||||
|
require.ErrorAs(t, err, &target)
|
||||||
} else {
|
} else {
|
||||||
require.Equal(t,
|
require.Equal(t,
|
||||||
payload[tc.rng.GetOffset():tc.rng.GetOffset()+tc.rng.GetLength()],
|
payload[tc.rng.GetOffset():tc.rng.GetOffset()+tc.rng.GetLength()],
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (c *cache) Delete(ctx context.Context, addr oid.Address) error {
|
||||||
it, err := tx.Get([]byte(saddr))
|
it, err := tx.Get([]byte(saddr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == badger.ErrKeyNotFound {
|
if err == badger.ErrKeyNotFound {
|
||||||
return logicerr.Wrap(apistatus.ObjectNotFound{})
|
return logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func (c *cache) getInternal(addr oid.Address) (*objectSDK.Object, error) {
|
||||||
return obj, obj.Unmarshal(value)
|
return obj, obj.Unmarshal(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Head returns object header from write-cache.
|
// Head returns object header from write-cache.
|
||||||
|
@ -79,7 +79,7 @@ func Get(db *badger.DB, key []byte) ([]byte, error) {
|
||||||
it, err := tx.Get(key)
|
it, err := tx.Get(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == badger.ErrKeyNotFound {
|
if err == badger.ErrKeyNotFound {
|
||||||
return logicerr.Wrap(apistatus.ObjectNotFound{})
|
return logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ func (c *cache) getInternal(ctx context.Context, saddr string, addr oid.Address)
|
||||||
|
|
||||||
res, err := c.fsTree.Get(ctx, common.GetPrm{Address: addr})
|
res, err := c.fsTree.Get(ctx, common.GetPrm{Address: addr})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
found = true
|
found = true
|
||||||
|
@ -93,7 +93,7 @@ func Get(db *bbolt.DB, key []byte) ([]byte, error) {
|
||||||
}
|
}
|
||||||
value = b.Get(key)
|
value = b.Get(key)
|
||||||
if value == nil {
|
if value == nil {
|
||||||
return logicerr.Wrap(apistatus.ObjectNotFound{})
|
return logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||||
}
|
}
|
||||||
value = slice.Copy(value)
|
value = slice.Copy(value)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -2,7 +2,6 @@ package writecachebbolt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -12,7 +11,7 @@ import (
|
||||||
storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log"
|
storagelog "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/log"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/writecache"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -98,7 +97,7 @@ func (c *cache) deleteFromDisk(ctx context.Context, keys []string) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.fsTree.Delete(ctx, common.DeletePrm{Address: addr})
|
_, err := c.fsTree.Delete(ctx, common.DeletePrm{Address: addr})
|
||||||
if err != nil && !errors.As(err, new(apistatus.ObjectNotFound)) {
|
if err != nil && !client.IsErrObjectNotFound(err) {
|
||||||
c.log.Error(logs.WritecacheCantRemoveObjectFromWritecache, zap.Error(err))
|
c.log.Error(logs.WritecacheCantRemoveObjectFromWritecache, zap.Error(err))
|
||||||
|
|
||||||
// Save the key for the next iteration.
|
// Save the key for the next iteration.
|
||||||
|
|
|
@ -55,9 +55,7 @@ func (c *Client) GetEACL(cnr cid.ID) (*container.EACL, error) {
|
||||||
// The absence of a signature in the response can be taken as an eACL absence criterion,
|
// The absence of a signature in the response can be taken as an eACL absence criterion,
|
||||||
// since unsigned table cannot be approved in the storage by design.
|
// since unsigned table cannot be approved in the storage by design.
|
||||||
if len(sig) == 0 {
|
if len(sig) == 0 {
|
||||||
var errEACLNotFound apistatus.EACLNotFound
|
return nil, new(apistatus.EACLNotFound)
|
||||||
|
|
||||||
return nil, errEACLNotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub, err := client.BytesFromStackItem(arr[2])
|
pub, err := client.BytesFromStackItem(arr[2])
|
||||||
|
|
|
@ -51,9 +51,7 @@ func (c *Client) Get(cid []byte) (*containercore.Container, error) {
|
||||||
res, err := c.client.TestInvoke(prm)
|
res, err := c.client.TestInvoke(prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), containerContract.NotFoundError) {
|
if strings.Contains(err.Error(), containerContract.NotFoundError) {
|
||||||
var errNotFound apistatus.ContainerNotFound
|
return nil, new(apistatus.ContainerNotFound)
|
||||||
|
|
||||||
return nil, errNotFound
|
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", getMethod, err)
|
return nil, fmt.Errorf("could not perform test invocation (%s): %w", getMethod, err)
|
||||||
} else if ln := len(res); ln != 1 {
|
} else if ln := len(res); ln != 1 {
|
||||||
|
|
|
@ -639,7 +639,7 @@ func (b Service) findRequestInfo(req MetaWithToken, idCnr cid.ID, op acl.Op) (in
|
||||||
return info, errors.New("can't fetch current epoch")
|
return info, errors.New("can't fetch current epoch")
|
||||||
}
|
}
|
||||||
if req.token.ExpiredAt(currentEpoch) {
|
if req.token.ExpiredAt(currentEpoch) {
|
||||||
return info, apistatus.SessionTokenExpired{}
|
return info, new(apistatus.SessionTokenExpired)
|
||||||
}
|
}
|
||||||
if req.token.InvalidAt(currentEpoch) {
|
if req.token.InvalidAt(currentEpoch) {
|
||||||
return info, fmt.Errorf("%s: token is invalid at %d epoch)",
|
return info, fmt.Errorf("%s: token is invalid at %d epoch)",
|
||||||
|
|
|
@ -32,11 +32,9 @@ func (x *Common) Init(state NodeState, nextHandler ServiceServer) {
|
||||||
x.nextHandler = nextHandler
|
x.nextHandler = nextHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
var errMaintenance apistatus.NodeUnderMaintenance
|
|
||||||
|
|
||||||
func (x *Common) Get(req *objectV2.GetRequest, stream GetObjectStream) error {
|
func (x *Common) Get(req *objectV2.GetRequest, stream GetObjectStream) error {
|
||||||
if x.state.IsMaintenance() {
|
if x.state.IsMaintenance() {
|
||||||
return errMaintenance
|
return new(apistatus.NodeUnderMaintenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x.nextHandler.Get(req, stream)
|
return x.nextHandler.Get(req, stream)
|
||||||
|
@ -44,7 +42,7 @@ func (x *Common) Get(req *objectV2.GetRequest, stream GetObjectStream) error {
|
||||||
|
|
||||||
func (x *Common) Put() (PutObjectStream, error) {
|
func (x *Common) Put() (PutObjectStream, error) {
|
||||||
if x.state.IsMaintenance() {
|
if x.state.IsMaintenance() {
|
||||||
return nil, errMaintenance
|
return nil, new(apistatus.NodeUnderMaintenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x.nextHandler.Put()
|
return x.nextHandler.Put()
|
||||||
|
@ -52,7 +50,7 @@ func (x *Common) Put() (PutObjectStream, error) {
|
||||||
|
|
||||||
func (x *Common) Head(ctx context.Context, req *objectV2.HeadRequest) (*objectV2.HeadResponse, error) {
|
func (x *Common) Head(ctx context.Context, req *objectV2.HeadRequest) (*objectV2.HeadResponse, error) {
|
||||||
if x.state.IsMaintenance() {
|
if x.state.IsMaintenance() {
|
||||||
return nil, errMaintenance
|
return nil, new(apistatus.NodeUnderMaintenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x.nextHandler.Head(ctx, req)
|
return x.nextHandler.Head(ctx, req)
|
||||||
|
@ -60,7 +58,7 @@ func (x *Common) Head(ctx context.Context, req *objectV2.HeadRequest) (*objectV2
|
||||||
|
|
||||||
func (x *Common) Search(req *objectV2.SearchRequest, stream SearchStream) error {
|
func (x *Common) Search(req *objectV2.SearchRequest, stream SearchStream) error {
|
||||||
if x.state.IsMaintenance() {
|
if x.state.IsMaintenance() {
|
||||||
return errMaintenance
|
return new(apistatus.NodeUnderMaintenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x.nextHandler.Search(req, stream)
|
return x.nextHandler.Search(req, stream)
|
||||||
|
@ -68,7 +66,7 @@ func (x *Common) Search(req *objectV2.SearchRequest, stream SearchStream) error
|
||||||
|
|
||||||
func (x *Common) Delete(ctx context.Context, req *objectV2.DeleteRequest) (*objectV2.DeleteResponse, error) {
|
func (x *Common) Delete(ctx context.Context, req *objectV2.DeleteRequest) (*objectV2.DeleteResponse, error) {
|
||||||
if x.state.IsMaintenance() {
|
if x.state.IsMaintenance() {
|
||||||
return nil, errMaintenance
|
return nil, new(apistatus.NodeUnderMaintenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x.nextHandler.Delete(ctx, req)
|
return x.nextHandler.Delete(ctx, req)
|
||||||
|
@ -76,7 +74,7 @@ func (x *Common) Delete(ctx context.Context, req *objectV2.DeleteRequest) (*obje
|
||||||
|
|
||||||
func (x *Common) GetRange(req *objectV2.GetRangeRequest, stream GetObjectRangeStream) error {
|
func (x *Common) GetRange(req *objectV2.GetRangeRequest, stream GetObjectRangeStream) error {
|
||||||
if x.state.IsMaintenance() {
|
if x.state.IsMaintenance() {
|
||||||
return errMaintenance
|
return new(apistatus.NodeUnderMaintenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x.nextHandler.GetRange(req, stream)
|
return x.nextHandler.GetRange(req, stream)
|
||||||
|
@ -84,7 +82,7 @@ func (x *Common) GetRange(req *objectV2.GetRangeRequest, stream GetObjectRangeSt
|
||||||
|
|
||||||
func (x *Common) GetRangeHash(ctx context.Context, req *objectV2.GetRangeHashRequest) (*objectV2.GetRangeHashResponse, error) {
|
func (x *Common) GetRangeHash(ctx context.Context, req *objectV2.GetRangeHashRequest) (*objectV2.GetRangeHashResponse, error) {
|
||||||
if x.state.IsMaintenance() {
|
if x.state.IsMaintenance() {
|
||||||
return nil, errMaintenance
|
return nil, new(apistatus.NodeUnderMaintenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x.nextHandler.GetRangeHash(ctx, req)
|
return x.nextHandler.GetRangeHash(ctx, req)
|
||||||
|
@ -92,7 +90,7 @@ func (x *Common) GetRangeHash(ctx context.Context, req *objectV2.GetRangeHashReq
|
||||||
|
|
||||||
func (x *Common) PutSingle(ctx context.Context, req *objectV2.PutSingleRequest) (*objectV2.PutSingleResponse, error) {
|
func (x *Common) PutSingle(ctx context.Context, req *objectV2.PutSingleRequest) (*objectV2.PutSingleResponse, error) {
|
||||||
if x.state.IsMaintenance() {
|
if x.state.IsMaintenance() {
|
||||||
return nil, errMaintenance
|
return nil, new(apistatus.NodeUnderMaintenance)
|
||||||
}
|
}
|
||||||
|
|
||||||
return x.nextHandler.PutSingle(ctx, req)
|
return x.nextHandler.PutSingle(ctx, req)
|
||||||
|
|
|
@ -63,8 +63,8 @@ func (r *request) assemble(ctx context.Context) {
|
||||||
var errSplitInfo *objectSDK.SplitInfoError
|
var errSplitInfo *objectSDK.SplitInfoError
|
||||||
var errRemovedRemote *apistatus.ObjectAlreadyRemoved
|
var errRemovedRemote *apistatus.ObjectAlreadyRemoved
|
||||||
var errOutOfRangeRemote *apistatus.ObjectOutOfRange
|
var errOutOfRangeRemote *apistatus.ObjectOutOfRange
|
||||||
var errRemovedLocal apistatus.ObjectAlreadyRemoved
|
var errRemovedLocal *apistatus.ObjectAlreadyRemoved
|
||||||
var errOutOfRangeLocal apistatus.ObjectOutOfRange
|
var errOutOfRangeLocal *apistatus.ObjectOutOfRange
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object_manager/placement"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object_manager/placement"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger/test"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger/test"
|
||||||
|
clientSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
|
@ -128,9 +129,7 @@ func (c *testClient) addResult(addr oid.Address, obj *objectSDK.Object, err erro
|
||||||
func (c *testClient) Get(ctx context.Context, address oid.Address, requestParams RemoteRequestParams) (*objectSDK.Object, error) {
|
func (c *testClient) Get(ctx context.Context, address oid.Address, requestParams RemoteRequestParams) (*objectSDK.Object, error) {
|
||||||
v, ok := c.results[address.EncodeToString()]
|
v, ok := c.results[address.EncodeToString()]
|
||||||
if !ok {
|
if !ok {
|
||||||
var errNotFound apistatus.ObjectNotFound
|
return nil, new(apistatus.ObjectNotFound)
|
||||||
|
|
||||||
return nil, errNotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.err != nil {
|
if v.err != nil {
|
||||||
|
@ -172,9 +171,7 @@ func (s *testStorage) Range(_ context.Context, address oid.Address, rng *objectS
|
||||||
)
|
)
|
||||||
|
|
||||||
if _, ok = s.inhumed[sAddr]; ok {
|
if _, ok = s.inhumed[sAddr]; ok {
|
||||||
var errRemoved apistatus.ObjectAlreadyRemoved
|
return nil, new(apistatus.ObjectAlreadyRemoved)
|
||||||
|
|
||||||
return nil, errRemoved
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if info, ok := s.virtual[sAddr]; ok {
|
if info, ok := s.virtual[sAddr]; ok {
|
||||||
|
@ -185,9 +182,7 @@ func (s *testStorage) Range(_ context.Context, address oid.Address, rng *objectS
|
||||||
return cutToRange(obj, rng), nil
|
return cutToRange(obj, rng), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNotFound apistatus.ObjectNotFound
|
return nil, new(apistatus.ObjectNotFound)
|
||||||
|
|
||||||
return nil, errNotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func cutToRange(o *objectSDK.Object, rng *objectSDK.Range) *objectSDK.Object {
|
func cutToRange(o *objectSDK.Object, rng *objectSDK.Range) *objectSDK.Object {
|
||||||
|
@ -374,19 +369,19 @@ func TestGetLocalOnly(t *testing.T) {
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
|
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, clientSDK.IsErrObjectAlreadyRemoved(err))
|
||||||
|
|
||||||
rngPrm := newRngPrm(false, nil, 0, 0)
|
rngPrm := newRngPrm(false, nil, 0, 0)
|
||||||
rngPrm.WithAddress(addr)
|
rngPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rngPrm)
|
err = svc.GetRange(ctx, rngPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, clientSDK.IsErrObjectAlreadyRemoved(err))
|
||||||
|
|
||||||
headPrm := newHeadPrm(false, nil)
|
headPrm := newHeadPrm(false, nil)
|
||||||
headPrm.WithAddress(addr)
|
headPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.Head(ctx, headPrm)
|
err = svc.Head(ctx, headPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
require.True(t, clientSDK.IsErrObjectAlreadyRemoved(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("404", func(t *testing.T) {
|
t.Run("404", func(t *testing.T) {
|
||||||
|
@ -401,20 +396,20 @@ func TestGetLocalOnly(t *testing.T) {
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
|
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
rngPrm := newRngPrm(false, nil, 0, 0)
|
rngPrm := newRngPrm(false, nil, 0, 0)
|
||||||
rngPrm.WithAddress(addr)
|
rngPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rngPrm)
|
err = svc.GetRange(ctx, rngPrm)
|
||||||
|
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
headPrm := newHeadPrm(false, nil)
|
headPrm := newHeadPrm(false, nil)
|
||||||
headPrm.WithAddress(addr)
|
headPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.Head(ctx, headPrm)
|
err = svc.Head(ctx, headPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("VIRTUAL", func(t *testing.T) {
|
t.Run("VIRTUAL", func(t *testing.T) {
|
||||||
|
@ -679,19 +674,19 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
p.WithAddress(addr)
|
p.WithAddress(addr)
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
require.ErrorAs(t, err, new(*apistatus.ObjectAlreadyRemoved))
|
require.True(t, clientSDK.IsErrObjectAlreadyRemoved(err))
|
||||||
|
|
||||||
rngPrm := newRngPrm(false, nil, 0, 0)
|
rngPrm := newRngPrm(false, nil, 0, 0)
|
||||||
rngPrm.WithAddress(addr)
|
rngPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rngPrm)
|
err = svc.GetRange(ctx, rngPrm)
|
||||||
require.ErrorAs(t, err, new(*apistatus.ObjectAlreadyRemoved))
|
require.True(t, clientSDK.IsErrObjectAlreadyRemoved(err))
|
||||||
|
|
||||||
headPrm := newHeadPrm(false, nil)
|
headPrm := newHeadPrm(false, nil)
|
||||||
headPrm.WithAddress(addr)
|
headPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.Head(ctx, headPrm)
|
err = svc.Head(ctx, headPrm)
|
||||||
require.ErrorAs(t, err, new(*apistatus.ObjectAlreadyRemoved))
|
require.True(t, clientSDK.IsErrObjectAlreadyRemoved(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("404", func(t *testing.T) {
|
t.Run("404", func(t *testing.T) {
|
||||||
|
@ -723,19 +718,19 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
p.WithAddress(addr)
|
p.WithAddress(addr)
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
rngPrm := newRngPrm(false, nil, 0, 0)
|
rngPrm := newRngPrm(false, nil, 0, 0)
|
||||||
rngPrm.WithAddress(addr)
|
rngPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rngPrm)
|
err = svc.GetRange(ctx, rngPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
headPrm := newHeadPrm(false, nil)
|
headPrm := newHeadPrm(false, nil)
|
||||||
headPrm.WithAddress(addr)
|
headPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.Head(ctx, headPrm)
|
err = svc.Head(ctx, headPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("VIRTUAL", func(t *testing.T) {
|
t.Run("VIRTUAL", func(t *testing.T) {
|
||||||
|
@ -768,11 +763,11 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
|
|
||||||
c1 := newTestClient()
|
c1 := newTestClient()
|
||||||
c1.addResult(addr, nil, errors.New("any error"))
|
c1.addResult(addr, nil, errors.New("any error"))
|
||||||
c1.addResult(splitAddr, nil, apistatus.ObjectNotFound{})
|
c1.addResult(splitAddr, nil, new(apistatus.ObjectNotFound))
|
||||||
|
|
||||||
c2 := newTestClient()
|
c2 := newTestClient()
|
||||||
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
||||||
c2.addResult(splitAddr, nil, apistatus.ObjectNotFound{})
|
c2.addResult(splitAddr, nil, new(apistatus.ObjectNotFound))
|
||||||
|
|
||||||
builder := &testPlacementBuilder{
|
builder := &testPlacementBuilder{
|
||||||
vectors: map[string][][]netmap.NodeInfo{
|
vectors: map[string][][]netmap.NodeInfo{
|
||||||
|
@ -794,13 +789,13 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
p.WithAddress(addr)
|
p.WithAddress(addr)
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
rngPrm := newRngPrm(false, nil, 0, 0)
|
rngPrm := newRngPrm(false, nil, 0, 0)
|
||||||
rngPrm.WithAddress(addr)
|
rngPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rngPrm)
|
err = svc.GetRange(ctx, rngPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("get chain element failure", func(t *testing.T) {
|
t.Run("get chain element failure", func(t *testing.T) {
|
||||||
|
@ -845,7 +840,7 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
||||||
c2.addResult(linkAddr, linkingObj, nil)
|
c2.addResult(linkAddr, linkingObj, nil)
|
||||||
c2.addResult(child1Addr, children[0], nil)
|
c2.addResult(child1Addr, children[0], nil)
|
||||||
c2.addResult(child2Addr, nil, apistatus.ObjectNotFound{})
|
c2.addResult(child2Addr, nil, new(apistatus.ObjectNotFound))
|
||||||
|
|
||||||
builder := &testPlacementBuilder{
|
builder := &testPlacementBuilder{
|
||||||
vectors: map[string][][]netmap.NodeInfo{
|
vectors: map[string][][]netmap.NodeInfo{
|
||||||
|
@ -869,13 +864,13 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
p.WithAddress(addr)
|
p.WithAddress(addr)
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
rngPrm := newRngPrm(false, NewSimpleObjectWriter(), 0, 1)
|
rngPrm := newRngPrm(false, NewSimpleObjectWriter(), 0, 1)
|
||||||
rngPrm.WithAddress(addr)
|
rngPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rngPrm)
|
err = svc.GetRange(ctx, rngPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("OK", func(t *testing.T) {
|
t.Run("OK", func(t *testing.T) {
|
||||||
|
@ -1315,11 +1310,11 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
|
|
||||||
c1 := newTestClient()
|
c1 := newTestClient()
|
||||||
c1.addResult(addr, nil, errors.New("any error"))
|
c1.addResult(addr, nil, errors.New("any error"))
|
||||||
c1.addResult(splitAddr, nil, apistatus.ObjectNotFound{})
|
c1.addResult(splitAddr, nil, new(apistatus.ObjectNotFound))
|
||||||
|
|
||||||
c2 := newTestClient()
|
c2 := newTestClient()
|
||||||
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
||||||
c2.addResult(splitAddr, nil, apistatus.ObjectNotFound{})
|
c2.addResult(splitAddr, nil, new(apistatus.ObjectNotFound))
|
||||||
|
|
||||||
builder := &testPlacementBuilder{
|
builder := &testPlacementBuilder{
|
||||||
vectors: map[string][][]netmap.NodeInfo{
|
vectors: map[string][][]netmap.NodeInfo{
|
||||||
|
@ -1341,13 +1336,13 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
p.WithAddress(addr)
|
p.WithAddress(addr)
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
rngPrm := newRngPrm(false, nil, 0, 0)
|
rngPrm := newRngPrm(false, nil, 0, 0)
|
||||||
rngPrm.WithAddress(addr)
|
rngPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rngPrm)
|
err = svc.GetRange(ctx, rngPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("get chain element failure", func(t *testing.T) {
|
t.Run("get chain element failure", func(t *testing.T) {
|
||||||
|
@ -1403,19 +1398,19 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
testHeadVirtual(svc, addr, splitInfo)
|
testHeadVirtual(svc, addr, splitInfo)
|
||||||
|
|
||||||
headSvc := newTestClient()
|
headSvc := newTestClient()
|
||||||
headSvc.addResult(preRightAddr, nil, apistatus.ObjectNotFound{})
|
headSvc.addResult(preRightAddr, nil, new(apistatus.ObjectNotFound))
|
||||||
|
|
||||||
p := newPrm(false, NewSimpleObjectWriter())
|
p := newPrm(false, NewSimpleObjectWriter())
|
||||||
p.WithAddress(addr)
|
p.WithAddress(addr)
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
rngPrm := newRngPrm(false, nil, 0, 1)
|
rngPrm := newRngPrm(false, nil, 0, 1)
|
||||||
rngPrm.WithAddress(addr)
|
rngPrm.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rngPrm)
|
err = svc.GetRange(ctx, rngPrm)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("child has different parent", func(t *testing.T) {
|
t.Run("child has different parent", func(t *testing.T) {
|
||||||
|
@ -1711,7 +1706,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
||||||
p.WithAddress(addr)
|
p.WithAddress(addr)
|
||||||
|
|
||||||
err := svc.Get(ctx, p)
|
err := svc.Get(ctx, p)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
commonPrm.SetNetmapLookupDepth(1)
|
commonPrm.SetNetmapLookupDepth(1)
|
||||||
|
|
||||||
|
@ -1734,7 +1729,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
||||||
rp.SetRange(r)
|
rp.SetRange(r)
|
||||||
|
|
||||||
err = svc.GetRange(ctx, rp)
|
err = svc.GetRange(ctx, rp)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
w = NewSimpleObjectWriter()
|
w = NewSimpleObjectWriter()
|
||||||
rp.SetChunkWriter(w)
|
rp.SetChunkWriter(w)
|
||||||
|
@ -1751,7 +1746,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
||||||
hp.WithAddress(addr)
|
hp.WithAddress(addr)
|
||||||
|
|
||||||
err = svc.Head(ctx, hp)
|
err = svc.Head(ctx, hp)
|
||||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||||
|
|
||||||
w = NewSimpleObjectWriter()
|
w = NewSimpleObjectWriter()
|
||||||
hp.SetHeaderWriter(w)
|
hp.SetHeaderWriter(w)
|
||||||
|
|
|
@ -22,8 +22,8 @@ func (r *request) executeLocal(ctx context.Context) {
|
||||||
r.collectedObject, err = r.get(ctx)
|
r.collectedObject, err = r.get(ctx)
|
||||||
|
|
||||||
var errSplitInfo *objectSDK.SplitInfoError
|
var errSplitInfo *objectSDK.SplitInfoError
|
||||||
var errRemoved apistatus.ObjectAlreadyRemoved
|
var errRemoved *apistatus.ObjectAlreadyRemoved
|
||||||
var errOutOfRange apistatus.ObjectOutOfRange
|
var errOutOfRange *apistatus.ObjectOutOfRange
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -31,10 +31,8 @@ func (r *request) processNode(ctx context.Context, info client.NodeInfo) bool {
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
var errNotFound apistatus.ObjectNotFound
|
|
||||||
|
|
||||||
r.status = statusUndefined
|
r.status = statusUndefined
|
||||||
r.err = errNotFound
|
r.err = new(apistatus.ObjectNotFound)
|
||||||
|
|
||||||
r.log.Debug(logs.GetRemoteCallFailed, zap.Error(err))
|
r.log.Debug(logs.GetRemoteCallFailed, zap.Error(err))
|
||||||
case err == nil:
|
case err == nil:
|
||||||
|
|
|
@ -3,7 +3,6 @@ package getsvc
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"errors"
|
|
||||||
"hash"
|
"hash"
|
||||||
|
|
||||||
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
||||||
|
@ -15,6 +14,7 @@ import (
|
||||||
objectSvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
|
objectSvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
|
||||||
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
||||||
|
clientSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
@ -154,7 +154,7 @@ func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.Ran
|
||||||
ID: tok.ID(),
|
ID: tok.ID(),
|
||||||
Owner: tok.Issuer(),
|
Owner: tok.Issuer(),
|
||||||
})
|
})
|
||||||
if err != nil && errors.As(err, new(apistatus.SessionTokenNotFound)) {
|
if err != nil && clientSDK.IsErrSessionNotFound(err) {
|
||||||
commonPrm.ForgetTokens()
|
commonPrm.ForgetTokens()
|
||||||
signerKey, err = s.keyStorage.GetKey(nil)
|
signerKey, err = s.keyStorage.GetKey(nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,16 +68,12 @@ func (s *KeyStorage) GetKey(info *SessionInfo) (*ecdsa.PrivateKey, error) {
|
||||||
pToken := s.tokenStore.Get(info.Owner, binID)
|
pToken := s.tokenStore.Get(info.Owner, binID)
|
||||||
if pToken != nil {
|
if pToken != nil {
|
||||||
if pToken.ExpiredAt() <= s.networkState.CurrentEpoch() {
|
if pToken.ExpiredAt() <= s.networkState.CurrentEpoch() {
|
||||||
var errExpired apistatus.SessionTokenExpired
|
return nil, new(apistatus.SessionTokenExpired)
|
||||||
|
|
||||||
return nil, errExpired
|
|
||||||
}
|
}
|
||||||
return pToken.SessionKey(), nil
|
return pToken.SessionKey(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNotFound apistatus.SessionTokenNotFound
|
return nil, new(apistatus.SessionTokenNotFound)
|
||||||
|
|
||||||
return nil, errNotFound
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.key, nil
|
return s.key, nil
|
||||||
|
|
|
@ -2,12 +2,11 @@ package tsourse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
||||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
)
|
)
|
||||||
|
@ -68,7 +67,7 @@ func (s Source) Tombstone(ctx context.Context, a oid.Address, _ uint64) (*object
|
||||||
|
|
||||||
err := s.s.Head(ctx, headPrm)
|
err := s.s.Head(ctx, headPrm)
|
||||||
switch {
|
switch {
|
||||||
case errors.As(err, new(apistatus.ObjectNotFound)) || errors.As(err, new(apistatus.ObjectAlreadyRemoved)):
|
case client.IsErrObjectNotFound(err) || client.IsErrObjectAlreadyRemoved(err):
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return nil, fmt.Errorf("could not get tombstone from the source: %w", err)
|
return nil, fmt.Errorf("could not get tombstone from the source: %w", err)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
|
||||||
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/replicator"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/replicator"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
|
@ -27,7 +26,7 @@ func (p *Policer) processObject(ctx context.Context, addrWithType objectcore.Add
|
||||||
zap.Stringer("cid", idCnr),
|
zap.Stringer("cid", idCnr),
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
)
|
)
|
||||||
if container.IsErrNotFound(err) {
|
if client.IsErrContainerNotFound(err) {
|
||||||
err := p.buryFn(ctx, addrWithType.Address)
|
err := p.buryFn(ctx, addrWithType.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.log.Error(logs.PolicerCouldNotInhumeObjectWithMissingContainer,
|
p.log.Error(logs.PolicerCouldNotInhumeObjectWithMissingContainer,
|
||||||
|
@ -218,7 +217,6 @@ func isClientErrMaintenance(err error) bool {
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
case
|
case
|
||||||
apistatus.NodeUnderMaintenance,
|
|
||||||
*apistatus.NodeUnderMaintenance:
|
*apistatus.NodeUnderMaintenance:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ func TestBuryObjectWithoutContainer(t *testing.T) {
|
||||||
// Container source and bury function
|
// Container source and bury function
|
||||||
buryCh := make(chan oid.Address)
|
buryCh := make(chan oid.Address)
|
||||||
containerSrc := func(id cid.ID) (*container.Container, error) {
|
containerSrc := func(id cid.ID) (*container.Container, error) {
|
||||||
return nil, apistatus.ContainerNotFound{}
|
return nil, new(apistatus.ContainerNotFound)
|
||||||
}
|
}
|
||||||
buryFn := func(ctx context.Context, a oid.Address) error {
|
buryFn := func(ctx context.Context, a oid.Address) error {
|
||||||
buryCh <- a
|
buryCh <- a
|
||||||
|
@ -187,7 +187,7 @@ func TestProcessObject(t *testing.T) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, apistatus.ObjectNotFound{}
|
return nil, new(apistatus.ObjectNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container source
|
// Container source
|
||||||
|
@ -199,7 +199,7 @@ func TestProcessObject(t *testing.T) {
|
||||||
return cnr, nil
|
return cnr, nil
|
||||||
}
|
}
|
||||||
t.Errorf("unexpected container requested: got=%v, want=%v", id, addr.Container())
|
t.Errorf("unexpected container requested: got=%v, want=%v", id, addr.Container())
|
||||||
return nil, apistatus.ContainerNotFound{}
|
return nil, new(apistatus.ContainerNotFound)
|
||||||
}
|
}
|
||||||
buryFn := func(ctx context.Context, a oid.Address) error {
|
buryFn := func(ctx context.Context, a oid.Address) error {
|
||||||
t.Errorf("unexpected object buried: %v", a)
|
t.Errorf("unexpected object buried: %v", a)
|
||||||
|
@ -252,7 +252,7 @@ func TestIteratorContract(t *testing.T) {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
containerSrc := func(id cid.ID) (*container.Container, error) {
|
containerSrc := func(id cid.ID) (*container.Container, error) {
|
||||||
return nil, apistatus.ContainerNotFound{}
|
return nil, new(apistatus.ContainerNotFound)
|
||||||
}
|
}
|
||||||
buryFn := func(ctx context.Context, a oid.Address) error {
|
buryFn := func(ctx context.Context, a oid.Address) error {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -51,7 +51,7 @@ func (s *SignService) SignResponse(resp ResponseMessage, err error) error {
|
||||||
|
|
||||||
func (s *SignService) VerifyRequest(req RequestMessage) error {
|
func (s *SignService) VerifyRequest(req RequestMessage) error {
|
||||||
if err := signature.VerifyServiceMessage(req); err != nil {
|
if err := signature.VerifyServiceMessage(req); err != nil {
|
||||||
var sigErr apistatus.SignatureVerification
|
sigErr := new(apistatus.SignatureVerification)
|
||||||
sigErr.SetMessage(err.Error())
|
sigErr.SetMessage(err.Error())
|
||||||
return sigErr
|
return sigErr
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue