[#481] Update frostfs-sdk-go and error pointer receivers
Some checks failed
Vulncheck / Vulncheck (pull_request) Failing after 4s
Build / Build Components (1.20) (pull_request) Failing after 2s
Tests and linters / Tests (1.19) (pull_request) Failing after 3s
Tests and linters / Tests (1.20) (pull_request) Failing after 3s
Tests and linters / Tests with -race (pull_request) Failing after 3s
Tests and linters / Staticcheck (pull_request) Failing after 2s
Build / Build Components (1.19) (pull_request) Successful in 12m9s
Tests and linters / Lint (pull_request) Successful in 16m12s
Some checks failed
Vulncheck / Vulncheck (pull_request) Failing after 4s
Build / Build Components (1.20) (pull_request) Failing after 2s
Tests and linters / Tests (1.19) (pull_request) Failing after 3s
Tests and linters / Tests (1.20) (pull_request) Failing after 3s
Tests and linters / Tests with -race (pull_request) Failing after 3s
Tests and linters / Staticcheck (pull_request) Failing after 2s
Build / Build Components (1.19) (pull_request) Successful in 12m9s
Tests and linters / Lint (pull_request) Successful in 16m12s
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
8d589314b5
commit
9c17964edf
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.
|
||||
func (x *GetContainerPrm) SetContainer(id cid.ID) {
|
||||
x.cliPrm.SetContainer(id)
|
||||
*x.cliPrm.ContainerID = id
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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
|
||||
|
|
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-contract v0.0.0-20230627134746-36f3d39c406a
|
||||
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/tzhash v1.8.0
|
||||
github.com/cheggaaa/pb v1.0.29
|
||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -1,9 +1,6 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
|
||||
|
@ -37,12 +34,6 @@ type Source interface {
|
|||
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
|
||||
// the FrostFS network.
|
||||
type EACL struct {
|
||||
|
|
|
@ -282,7 +282,7 @@ func (c *testContainerClient) Get(cid []byte) (*containercore.Container, error)
|
|||
if cont, found := c.get[key]; found {
|
||||
return cont, nil
|
||||
}
|
||||
return nil, apistatus.ContainerNotFound{}
|
||||
return nil, new(apistatus.ContainerNotFound)
|
||||
}
|
||||
|
||||
type testIDClient struct {
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"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"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -77,7 +78,7 @@ func TestBlobovnicza(t *testing.T) {
|
|||
require.NoError(t, blz.Init())
|
||||
|
||||
// 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)
|
||||
|
||||
|
@ -92,7 +93,7 @@ func TestBlobovnicza(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
// should return 404
|
||||
testGet(t, blz, addr, nil, IsErrNotFound)
|
||||
testGet(t, blz, addr, nil, client.IsErrObjectNotFound)
|
||||
|
||||
// fill Blobovnicza fully
|
||||
for ; filled < sizeLim; filled += objSizeLim {
|
||||
|
|
|
@ -77,9 +77,7 @@ func (b *Blobovnicza) Delete(ctx context.Context, prm DeletePrm) (DeleteRes, err
|
|||
})
|
||||
|
||||
if err == nil && !found {
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
return DeleteRes{}, errNotFound
|
||||
return DeleteRes{}, new(apistatus.ObjectNotFound)
|
||||
}
|
||||
|
||||
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 {
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
return GetRes{}, errNotFound
|
||||
return GetRes{}, new(apistatus.ObjectNotFound)
|
||||
}
|
||||
|
||||
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/util/logicerr"
|
||||
"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"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"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)
|
||||
if err != nil {
|
||||
if !blobovnicza.IsErrNotFound(err) {
|
||||
if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromLevel,
|
||||
zap.String("level", p),
|
||||
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 {
|
||||
// not found in any blobovnicza
|
||||
return common.DeleteRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return common.DeleteRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
success = err == nil
|
||||
|
||||
|
@ -109,7 +110,7 @@ func (b *Blobovniczas) deleteObjectFromLevel(ctx context.Context, prm blobovnicz
|
|||
if ok {
|
||||
if res, err := b.deleteObject(ctx, v, prm); err == nil {
|
||||
return res, err
|
||||
} else if !blobovnicza.IsErrNotFound(err) {
|
||||
} else if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromOpenedBlobovnicza,
|
||||
zap.String("path", blzPath),
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -128,7 +129,7 @@ func (b *Blobovniczas) deleteObjectFromLevel(ctx context.Context, prm blobovnicz
|
|||
if ok && tryActive {
|
||||
if res, err := b.deleteObject(ctx, active.blz, prm); err == nil {
|
||||
return res, err
|
||||
} else if !blobovnicza.IsErrNotFound(err) {
|
||||
} else if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotRemoveObjectFromActiveBlobovnicza,
|
||||
zap.String("path", blzPath),
|
||||
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,
|
||||
// and it's pointless to open them).
|
||||
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)
|
||||
|
|
|
@ -8,7 +8,8 @@ import (
|
|||
)
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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/blobstor/common"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"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)
|
||||
if err != nil {
|
||||
if !blobovnicza.IsErrNotFound(err) {
|
||||
if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
||||
zap.String("level", p),
|
||||
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/util/logicerr"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"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)
|
||||
if err != nil {
|
||||
if !blobovnicza.IsErrNotFound(err) {
|
||||
if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
||||
zap.String("level", p),
|
||||
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 {
|
||||
// not found in any blobovnicza
|
||||
return res, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return res, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
|
||||
success = true
|
||||
|
@ -107,7 +108,7 @@ func (b *Blobovniczas) getObjectFromLevel(ctx context.Context, prm blobovnicza.G
|
|||
if ok {
|
||||
if res, err := b.getObject(ctx, v, prm); err == nil {
|
||||
return res, err
|
||||
} else if !blobovnicza.IsErrNotFound(err) {
|
||||
} else if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotReadObjectFromOpenedBlobovnicza,
|
||||
zap.String("path", blzPath),
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -127,7 +128,7 @@ func (b *Blobovniczas) getObjectFromLevel(ctx context.Context, prm blobovnicza.G
|
|||
if ok && tryActive {
|
||||
if res, err := b.getObject(ctx, active.blz, prm); err == nil {
|
||||
return res, err
|
||||
} else if !blobovnicza.IsErrNotFound(err) {
|
||||
} else if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromActiveBlobovnicza,
|
||||
zap.String("path", blzPath),
|
||||
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,
|
||||
// and it's pointless to open them).
|
||||
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)
|
||||
|
|
|
@ -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/util/logicerr"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"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)
|
||||
if err != nil {
|
||||
outOfBounds := isErrOutOfRange(err)
|
||||
if !outOfBounds && !blobovnicza.IsErrNotFound(err) {
|
||||
if !outOfBounds && !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotGetObjectFromLevel,
|
||||
zap.String("level", p),
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -91,7 +92,7 @@ func (b *Blobovniczas) GetRange(ctx context.Context, prm common.GetRangePrm) (re
|
|||
|
||||
if err == nil && !objectFound {
|
||||
// not found in any blobovnicza
|
||||
return common.GetRangeRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return common.GetRangeRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
|
@ -119,7 +120,7 @@ func (b *Blobovniczas) getRangeFromLevel(ctx context.Context, prm common.GetRang
|
|||
isErrOutOfRange(err):
|
||||
return res, err
|
||||
default:
|
||||
if !blobovnicza.IsErrNotFound(err) {
|
||||
if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotReadPayloadRangeFromOpenedBlobovnicza,
|
||||
zap.String("path", blzPath),
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -144,7 +145,7 @@ func (b *Blobovniczas) getRangeFromLevel(ctx context.Context, prm common.GetRang
|
|||
isErrOutOfRange(err):
|
||||
return res, err
|
||||
default:
|
||||
if !blobovnicza.IsErrNotFound(err) {
|
||||
if !client.IsErrObjectNotFound(err) {
|
||||
b.log.Debug(logs.BlobovniczatreeCouldNotReadPayloadRangeFromActiveBlobovnicza,
|
||||
zap.String("path", blzPath),
|
||||
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,
|
||||
// and it's pointless to open them).
|
||||
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)
|
||||
|
@ -202,7 +203,7 @@ func (b *Blobovniczas) getObjectRange(ctx context.Context, blz *blobovnicza.Blob
|
|||
payload := obj.Payload()
|
||||
|
||||
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{
|
||||
|
|
|
@ -3,12 +3,11 @@ package blobstor
|
|||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||
"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/trace"
|
||||
)
|
||||
|
@ -35,7 +34,7 @@ func (b *BlobStor) Delete(ctx context.Context, prm common.DeletePrm) (common.Del
|
|||
if prm.StorageID == nil {
|
||||
for i := range b.storage {
|
||||
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 {
|
||||
success = true
|
||||
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)
|
||||
if err != nil && os.IsNotExist(err) {
|
||||
err = logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
err = logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
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)
|
||||
|
||||
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
|
||||
|
@ -498,7 +498,7 @@ func (t *FSTree) GetRange(ctx context.Context, prm common.GetRangePrm) (common.G
|
|||
to := from + prm.Range.GetLength()
|
||||
|
||||
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
|
||||
|
|
|
@ -3,12 +3,12 @@ package blobstor
|
|||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"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-observability/tracing"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"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 {
|
||||
for i := range b.storage {
|
||||
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 common.GetRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return common.GetRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
if len(prm.StorageID) == 0 {
|
||||
res, err = b.storage[len(b.storage)-1].Storage.Get(ctx, prm)
|
||||
|
|
|
@ -3,13 +3,13 @@ package blobstor
|
|||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"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-observability/tracing"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"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 {
|
||||
for i := range b.storage {
|
||||
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 common.GetRangeRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return common.GetRangeRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
if len(prm.StorageID) == 0 {
|
||||
res, err = b.storage[len(b.storage)-1].Storage.GetRange(ctx, prm)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"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"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -23,7 +23,7 @@ func TestDelete(t *testing.T, cons Constructor, min, max uint64) {
|
|||
prm.Address = oidtest.Address()
|
||||
|
||||
_, 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) {
|
||||
|
@ -43,12 +43,12 @@ func TestDelete(t *testing.T, cons Constructor, min, max uint64) {
|
|||
t.Run("get fail", func(t *testing.T) {
|
||||
prm := common.GetPrm{Address: oidtest.Address()}
|
||||
_, 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) {
|
||||
prm := common.GetRangePrm{Address: oidtest.Address()}
|
||||
_, 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) {
|
||||
|
@ -68,7 +68,7 @@ func TestDelete(t *testing.T, cons Constructor, min, max uint64) {
|
|||
require.NoError(t, err)
|
||||
|
||||
_, 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) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"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"
|
||||
"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) {
|
||||
gPrm := common.GetPrm{Address: oidtest.Address()}
|
||||
_, err := s.Get(context.Background(), gPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, client.IsErrObjectNotFound(err))
|
||||
})
|
||||
|
||||
for i := range objects {
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"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"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
"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) {
|
||||
gPrm := common.GetRangePrm{Address: oidtest.Address()}
|
||||
_, err := s.GetRange(context.Background(), gPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, client.IsErrObjectNotFound(err))
|
||||
})
|
||||
|
||||
payload := objects[0].obj.Payload()
|
||||
|
@ -56,7 +57,7 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
|||
gPrm.Range.SetLength(10)
|
||||
|
||||
_, 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) {
|
||||
|
@ -64,7 +65,7 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
|||
gPrm.Range.SetLength(uint64(len(payload)))
|
||||
|
||||
_, 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) {
|
||||
|
@ -72,7 +73,7 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
|||
gPrm.Range.SetLength(1 << 63)
|
||||
|
||||
_, 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) {
|
||||
|
@ -80,6 +81,6 @@ func TestGetRange(t *testing.T, cons Constructor, min, max uint64) {
|
|||
gPrm.Range.SetLength(math.MaxUint64 - 2)
|
||||
|
||||
_, 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()
|
||||
|
||||
if !exists {
|
||||
return common.GetRes{}, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return common.GetRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
|
||||
// Decompress the data.
|
||||
|
@ -73,7 +73,7 @@ func (s *memstoreImpl) GetRange(ctx context.Context, req common.GetRangePrm) (co
|
|||
to := from + req.Range.GetLength()
|
||||
|
||||
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{
|
||||
|
@ -123,7 +123,7 @@ func (s *memstoreImpl) Delete(_ context.Context, req common.DeletePrm) (common.D
|
|||
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) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
|
@ -71,8 +72,7 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) (DeleteRes, e
|
|||
}
|
||||
|
||||
var locked struct {
|
||||
is bool
|
||||
err apistatus.ObjectLocked
|
||||
is bool
|
||||
}
|
||||
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)
|
||||
if err != nil {
|
||||
if shard.IsErrRemoved(err) || shard.IsErrObjectExpired(err) {
|
||||
if client.IsErrObjectAlreadyRemoved(err) || shard.IsErrObjectExpired(err) {
|
||||
return true
|
||||
}
|
||||
|
||||
var splitErr *objectSDK.SplitInfoError
|
||||
if !errors.As(err, &splitErr) {
|
||||
if !shard.IsErrNotFound(err) {
|
||||
if !client.IsErrObjectNotFound(err) {
|
||||
e.reportShardError(sh, "could not check object existence", err)
|
||||
}
|
||||
return false
|
||||
|
@ -111,7 +111,8 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) (DeleteRes, e
|
|||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
@ -121,7 +122,7 @@ func (e *StorageEngine) delete(ctx context.Context, prm DeletePrm) (DeleteRes, e
|
|||
})
|
||||
|
||||
if locked.is {
|
||||
return DeleteRes{}, locked.err
|
||||
return DeleteRes{}, new(apistatus.ObjectLocked)
|
||||
}
|
||||
|
||||
if splitInfo != nil {
|
||||
|
|
|
@ -65,16 +65,14 @@ func TestDeleteBigObject(t *testing.T) {
|
|||
}
|
||||
require.NoError(t, Put(context.Background(), e, link))
|
||||
|
||||
var splitErr *objectSDK.SplitInfoError
|
||||
|
||||
addrParent := object.AddressOf(parent)
|
||||
checkGetError(t, e, addrParent, &splitErr)
|
||||
checkGetError[*objectSDK.SplitInfoError](t, e, addrParent, true)
|
||||
|
||||
addrLink := object.AddressOf(link)
|
||||
checkGetError(t, e, addrLink, nil)
|
||||
checkGetError[error](t, e, addrLink, false)
|
||||
|
||||
for i := range children {
|
||||
checkGetError(t, e, object.AddressOf(children[i]), nil)
|
||||
checkGetError[error](t, e, object.AddressOf(children[i]), false)
|
||||
}
|
||||
|
||||
var deletePrm DeletePrm
|
||||
|
@ -84,20 +82,21 @@ func TestDeleteBigObject(t *testing.T) {
|
|||
_, err := e.Delete(context.Background(), deletePrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
checkGetError(t, e, addrParent, &apistatus.ObjectNotFound{})
|
||||
checkGetError(t, e, addrLink, &apistatus.ObjectNotFound{})
|
||||
checkGetError[*apistatus.ObjectNotFound](t, e, addrParent, true)
|
||||
checkGetError[*apistatus.ObjectNotFound](t, e, addrLink, true)
|
||||
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
|
||||
getPrm.WithAddress(addr)
|
||||
|
||||
_, err := e.Get(context.Background(), getPrm)
|
||||
if expected != nil {
|
||||
require.ErrorAs(t, err, expected)
|
||||
if shouldFail {
|
||||
var target E
|
||||
require.ErrorAs(t, err, &target)
|
||||
} else {
|
||||
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/mode"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"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())
|
||||
|
||||
_, 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)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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) {
|
||||
res, err := sh.Exists(ctx, shPrm)
|
||||
if err != nil {
|
||||
if shard.IsErrRemoved(err) {
|
||||
if client.IsErrObjectAlreadyRemoved(err) {
|
||||
alreadyRemoved = true
|
||||
|
||||
return true
|
||||
|
@ -34,7 +35,7 @@ func (e *StorageEngine) exists(ctx context.Context, addr oid.Address) (bool, err
|
|||
return true
|
||||
}
|
||||
|
||||
if !shard.IsErrNotFound(err) {
|
||||
if !client.IsErrObjectNotFound(err) {
|
||||
e.reportShardError(sh, "could not check existence of object in shard", err)
|
||||
}
|
||||
return false
|
||||
|
@ -48,9 +49,7 @@ func (e *StorageEngine) exists(ctx context.Context, addr oid.Address) (bool, err
|
|||
})
|
||||
|
||||
if alreadyRemoved {
|
||||
var errRemoved apistatus.ObjectAlreadyRemoved
|
||||
|
||||
return false, errRemoved
|
||||
return false, new(apistatus.ObjectAlreadyRemoved)
|
||||
}
|
||||
|
||||
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/logicerr"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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)()
|
||||
}
|
||||
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
errNotFound := new(apistatus.ObjectNotFound)
|
||||
|
||||
var shPrm shard.GetPrm
|
||||
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.HasDegraded && it.ShardWithMeta.Shard == nil || !shard.IsErrNotFound(it.OutError) {
|
||||
if !it.HasDegraded && it.ShardWithMeta.Shard == nil || !client.IsErrObjectNotFound(it.OutError) {
|
||||
return GetRes{}, it.OutError
|
||||
}
|
||||
|
||||
|
@ -144,7 +145,7 @@ func (i *getShardIterator) tryGetWithMeta(ctx context.Context) {
|
|||
i.MetaError = err
|
||||
}
|
||||
switch {
|
||||
case shard.IsErrNotFound(err):
|
||||
case client.IsErrObjectNotFound(err):
|
||||
return false // ignore, go to next shard
|
||||
case errors.As(err, &i.splitInfoErr):
|
||||
if i.SplitInfo == nil {
|
||||
|
@ -158,7 +159,7 @@ func (i *getShardIterator) tryGetWithMeta(ctx context.Context) {
|
|||
|
||||
// stop iterating over shards if SplitInfo structure is complete
|
||||
return withLink && withLast
|
||||
case shard.IsErrRemoved(err):
|
||||
case client.IsErrObjectAlreadyRemoved(err):
|
||||
i.OutError = err
|
||||
return true // stop, return it back
|
||||
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/logicerr"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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 (
|
||||
head *objectSDK.Object
|
||||
siErr *objectSDK.SplitInfoError
|
||||
outSI *objectSDK.SplitInfo
|
||||
|
||||
errNotFound apistatus.ObjectNotFound
|
||||
|
||||
outSI *objectSDK.SplitInfo
|
||||
outError error = errNotFound
|
||||
outError error = new(apistatus.ObjectNotFound)
|
||||
)
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
switch {
|
||||
case shard.IsErrNotFound(err):
|
||||
case client.IsErrObjectNotFound(err):
|
||||
return false // ignore, go to next shard
|
||||
case errors.As(err, &siErr):
|
||||
if outSI == nil {
|
||||
|
@ -107,16 +106,14 @@ func (e *StorageEngine) head(ctx context.Context, prm HeadPrm) (HeadRes, error)
|
|||
}
|
||||
|
||||
return false
|
||||
case shard.IsErrRemoved(err):
|
||||
case client.IsErrObjectAlreadyRemoved(err):
|
||||
outError = err
|
||||
|
||||
return true // stop, return it back
|
||||
case shard.IsErrObjectExpired(err):
|
||||
var notFoundErr apistatus.ObjectNotFound
|
||||
|
||||
// object is found but should not
|
||||
// be returned
|
||||
outError = notFoundErr
|
||||
outError = new(apistatus.ObjectNotFound)
|
||||
|
||||
return true
|
||||
default:
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
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-observability/tracing"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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.Stringer("addr", prm.addrs[i]))
|
||||
} else if locked {
|
||||
var lockedErr apistatus.ObjectLocked
|
||||
return InhumeRes{}, lockedErr
|
||||
return InhumeRes{}, new(apistatus.ObjectLocked)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
func (e *StorageEngine) inhumeAddr(ctx context.Context, addr oid.Address, prm shard.InhumePrm, checkExists bool) (bool, error) {
|
||||
root := false
|
||||
var errLocked apistatus.ObjectLocked
|
||||
var existPrm shard.ExistsPrm
|
||||
var retErr error
|
||||
var ok bool
|
||||
|
@ -143,7 +142,7 @@ func (e *StorageEngine) inhumeAddr(ctx context.Context, addr oid.Address, prm sh
|
|||
existPrm.SetAddress(addr)
|
||||
exRes, err := sh.Exists(ctx, existPrm)
|
||||
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
|
||||
ok = true
|
||||
return true
|
||||
|
@ -163,9 +162,10 @@ func (e *StorageEngine) inhumeAddr(ctx context.Context, addr oid.Address, prm sh
|
|||
|
||||
_, err := sh.Inhume(ctx, prm)
|
||||
if err != nil {
|
||||
var errLocked *apistatus.ObjectLocked
|
||||
switch {
|
||||
case errors.As(err, &errLocked):
|
||||
retErr = apistatus.ObjectLocked{}
|
||||
retErr = new(apistatus.ObjectLocked)
|
||||
return true
|
||||
case errors.Is(err, shard.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 {
|
||||
switch e.lockSingle(ctx, idCnr, locker, locked[i], true) {
|
||||
case 1:
|
||||
return logicerr.Wrap(apistatus.LockNonRegularObject{})
|
||||
return logicerr.Wrap(new(apistatus.LockNonRegularObject))
|
||||
case 0:
|
||||
switch e.lockSingle(ctx, idCnr, locker, locked[i], false) {
|
||||
case 1:
|
||||
return logicerr.Wrap(apistatus.LockNonRegularObject{})
|
||||
return logicerr.Wrap(new(apistatus.LockNonRegularObject))
|
||||
case 0:
|
||||
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) {
|
||||
// code is pretty similar to inhumeAddr, maybe unify?
|
||||
root := false
|
||||
var errIrregular apistatus.LockNonRegularObject
|
||||
|
||||
var addrLocked oid.Address
|
||||
addrLocked.SetContainer(idCnr)
|
||||
|
@ -105,6 +104,7 @@ func (e *StorageEngine) lockSingle(ctx context.Context, idCnr cid.ID, locker, lo
|
|||
if err != nil {
|
||||
e.reportShardError(sh, "could not lock object in shard", err)
|
||||
|
||||
var errIrregular *apistatus.LockNonRegularObject
|
||||
if errors.As(err, &errIrregular) {
|
||||
status = 1
|
||||
return true
|
||||
|
|
|
@ -119,8 +119,9 @@ func TestLockUserScenario(t *testing.T) {
|
|||
var inhumePrm InhumePrm
|
||||
inhumePrm.WithTarget(tombAddr, objAddr)
|
||||
|
||||
var objLockedErr *apistatus.ObjectLocked
|
||||
_, err = e.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
require.ErrorAs(t, err, &objLockedErr)
|
||||
|
||||
// 4.
|
||||
tombObj.SetType(objectSDK.TypeTombstone)
|
||||
|
@ -208,8 +209,9 @@ func TestLockExpiration(t *testing.T) {
|
|||
var inhumePrm InhumePrm
|
||||
inhumePrm.WithTarget(oidtest.Address(), objectcore.AddressOf(obj))
|
||||
|
||||
var objLockedErr *apistatus.ObjectLocked
|
||||
_, err = e.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
require.ErrorAs(t, err, &objLockedErr)
|
||||
|
||||
// 3.
|
||||
e.HandleNewEpoch(lockerExpiresAfter + 1)
|
||||
|
@ -281,13 +283,14 @@ func TestLockForceRemoval(t *testing.T) {
|
|||
var inhumePrm InhumePrm
|
||||
inhumePrm.MarkAsGarbage(objectcore.AddressOf(obj))
|
||||
|
||||
var objLockedErr *apistatus.ObjectLocked
|
||||
_, 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))
|
||||
|
||||
_, err = e.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
require.ErrorAs(t, err, &objLockedErr)
|
||||
|
||||
// 4.
|
||||
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/logicerr"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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)()
|
||||
}
|
||||
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
var shPrm shard.RngPrm
|
||||
shPrm.SetAddress(prm.addr)
|
||||
shPrm.SetRange(prm.off, prm.ln)
|
||||
|
||||
it := &getRangeShardIterator{
|
||||
OutError: errNotFound,
|
||||
OutError: new(apistatus.ObjectNotFound),
|
||||
ShardPrm: shPrm,
|
||||
Address: prm.addr,
|
||||
Engine: e,
|
||||
|
@ -105,7 +104,7 @@ func (e *StorageEngine) getRange(ctx context.Context, prm RngPrm) (RngRes, error
|
|||
if it.Object == nil {
|
||||
// If any shard is in a degraded mode, we should assume that metabase could store
|
||||
// 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
|
||||
}
|
||||
|
||||
|
@ -171,7 +170,7 @@ func (i *getRangeShardIterator) tryGetWithMeta(ctx context.Context) {
|
|||
i.MetaError = err
|
||||
}
|
||||
switch {
|
||||
case shard.IsErrNotFound(err):
|
||||
case client.IsErrObjectNotFound(err):
|
||||
return false // ignore, go to next shard
|
||||
case errors.As(err, &i.SplitInfoError):
|
||||
if i.SplitInfo == nil {
|
||||
|
@ -186,7 +185,7 @@ func (i *getRangeShardIterator) tryGetWithMeta(ctx context.Context) {
|
|||
// stop iterating over shards if SplitInfo structure is complete
|
||||
return withLink && withLast
|
||||
case
|
||||
shard.IsErrRemoved(err),
|
||||
client.IsErrObjectAlreadyRemoved(err),
|
||||
shard.IsErrOutOfRange(err):
|
||||
i.OutError = err
|
||||
|
||||
|
@ -212,9 +211,7 @@ func (i *getRangeShardIterator) tryGetFromBlobstor(ctx context.Context) {
|
|||
|
||||
res, err := sh.GetRange(ctx, i.ShardPrm)
|
||||
if shard.IsErrOutOfRange(err) {
|
||||
var errOutOfRange apistatus.ObjectOutOfRange
|
||||
|
||||
i.OutError = errOutOfRange
|
||||
i.OutError = new(apistatus.ObjectOutOfRange)
|
||||
return true
|
||||
}
|
||||
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/local_object_storage/internal/testutil"
|
||||
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"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -43,7 +44,7 @@ func TestReset(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
assertExists(addr, true, nil)
|
||||
assertExists(addrToInhume, false, meta.IsErrRemoved)
|
||||
assertExists(addrToInhume, false, client.IsErrObjectAlreadyRemoved)
|
||||
|
||||
err = db.Reset()
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
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-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"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"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)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||
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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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
|
||||
|
||||
ok, err := metaExists(db, object.AddressOf(child))
|
||||
require.ErrorAs(t, err, &apistatus.ObjectAlreadyRemoved{})
|
||||
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||
require.False(t, ok)
|
||||
|
||||
ok, err = metaExists(db, object.AddressOf(parent))
|
||||
require.ErrorAs(t, err, &apistatus.ObjectAlreadyRemoved{})
|
||||
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||
require.False(t, ok)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"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
|
||||
// epoch is less than the current one. Such objects are considered
|
||||
// as removed and should not be returned from the Storage Engine.
|
||||
var ErrObjectIsExpired = logicerr.New("object is expired")
|
||||
|
||||
// IsErrRemoved checks if error returned by Shard Exists/Get/Put method
|
||||
// corresponds to removed object.
|
||||
func IsErrRemoved(err error) bool {
|
||||
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
|
||||
switch objectStatus(tx, addr, currEpoch) {
|
||||
case 1:
|
||||
return false, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return false, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
case 2:
|
||||
return false, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
|
||||
return false, logicerr.Wrap(new(apistatus.ObjectAlreadyRemoved))
|
||||
case 3:
|
||||
return false, ErrObjectIsExpired
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||
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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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)
|
||||
|
||||
exists, err := metaExists(db, object.AddressOf(regular))
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||
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 {
|
||||
switch objectStatus(tx, addr, currEpoch) {
|
||||
case 1:
|
||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
case 2:
|
||||
return nil, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{})
|
||||
return nil, logicerr.Wrap(new(apistatus.ObjectAlreadyRemoved))
|
||||
case 3:
|
||||
return nil, ErrObjectIsExpired
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ func getVirtualObject(tx *bbolt.Tx, cnr cid.ID, key []byte, raw bool) (*objectSD
|
|||
bucketName := make([]byte, bucketKeySize)
|
||||
parentBucket := tx.Bucket(parentBucketName(cnr, bucketName))
|
||||
if parentBucket == nil {
|
||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -171,7 +171,7 @@ func getVirtualObject(tx *bbolt.Tx, cnr cid.ID, key []byte, raw bool) (*objectSD
|
|||
par := child.Parent()
|
||||
|
||||
if par == nil { // this should never happen though
|
||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
|
||||
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(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/local_object_storage/internal/testutil"
|
||||
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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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))
|
||||
_, err := metaGet(db, obj, false)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||
|
||||
obj = oidtest.Address()
|
||||
|
||||
|
@ -124,7 +124,7 @@ func TestDB_Get(t *testing.T) {
|
|||
_, err = db.Inhume(context.Background(), prm)
|
||||
require.NoError(t, err)
|
||||
_, 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) {
|
||||
|
|
|
@ -166,7 +166,7 @@ func (db *DB) inhumeTx(tx *bbolt.Tx, epoch uint64, prm InhumePrm, res *InhumeRes
|
|||
|
||||
// prevent locked objects to be inhumed
|
||||
if !prm.forceRemoval && objectLocked(tx, cnr, id) {
|
||||
return apistatus.ObjectLocked{}
|
||||
return new(apistatus.ObjectLocked)
|
||||
}
|
||||
|
||||
var lockWasChecked bool
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||
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"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
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)
|
||||
|
||||
_, 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)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||
}
|
||||
|
||||
func TestInhumeTombOnTomb(t *testing.T) {
|
||||
|
@ -58,7 +59,7 @@ func TestInhumeTombOnTomb(t *testing.T) {
|
|||
|
||||
// addr1 should become inhumed {addr1:addr2}
|
||||
_, err = db.Exists(context.Background(), existsPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||
|
||||
inhumePrm.SetAddresses(addr3)
|
||||
inhumePrm.SetTombstoneAddress(addr1)
|
||||
|
@ -72,13 +73,13 @@ func TestInhumeTombOnTomb(t *testing.T) {
|
|||
// NOT ObjectAlreadyRemoved since that record has been removed
|
||||
// from graveyard but addr1 is still marked with GC
|
||||
_, err = db.Exists(context.Background(), existsPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, client.IsErrObjectNotFound(err))
|
||||
|
||||
existsPrm.SetAddress(addr3)
|
||||
|
||||
// addr3 should be inhumed {addr3: addr1}
|
||||
_, err = db.Exists(context.Background(), existsPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||
|
||||
inhumePrm.SetAddresses(addr1)
|
||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||
|
@ -93,7 +94,7 @@ func TestInhumeTombOnTomb(t *testing.T) {
|
|||
// (tomb can not be inhumed) but should be kept as object
|
||||
// with GC mark
|
||||
_, err = db.Exists(context.Background(), existsPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, client.IsErrObjectNotFound(err))
|
||||
}
|
||||
|
||||
func TestInhumeLocked(t *testing.T) {
|
||||
|
@ -109,7 +110,7 @@ func TestInhumeLocked(t *testing.T) {
|
|||
|
||||
_, err = db.Inhume(context.Background(), prm)
|
||||
|
||||
var e apistatus.ObjectLocked
|
||||
var e *apistatus.ObjectLocked
|
||||
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 {
|
||||
if firstIrregularObjectType(tx, cnr, bucketKeysLocked...) != objectSDK.TypeRegular {
|
||||
return logicerr.Wrap(apistatus.LockNonRegularObject{})
|
||||
return logicerr.Wrap(new(apistatus.LockNonRegularObject))
|
||||
}
|
||||
|
||||
bucketLocked := tx.Bucket(bucketNameLocked)
|
||||
|
|
|
@ -41,7 +41,7 @@ func TestDB_Lock(t *testing.T) {
|
|||
err := metaPut(db, obj, nil)
|
||||
require.NoError(t, err, typ)
|
||||
|
||||
var e apistatus.LockNonRegularObject
|
||||
var e *apistatus.LockNonRegularObject
|
||||
|
||||
id, _ := obj.ID()
|
||||
|
||||
|
@ -66,13 +66,15 @@ func TestDB_Lock(t *testing.T) {
|
|||
|
||||
// check locking relation
|
||||
|
||||
var objLockedErr *apistatus.ObjectLocked
|
||||
|
||||
inhumePrm.SetAddresses(objAddr)
|
||||
_, err := db.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
require.ErrorAs(t, err, &objLockedErr)
|
||||
|
||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
require.ErrorAs(t, err, &objLockedErr)
|
||||
|
||||
// try to remove lock object
|
||||
inhumePrm.SetAddresses(lockAddr)
|
||||
|
@ -84,11 +86,11 @@ func TestDB_Lock(t *testing.T) {
|
|||
|
||||
inhumePrm.SetAddresses(objAddr)
|
||||
_, err = db.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
require.ErrorAs(t, err, &objLockedErr)
|
||||
|
||||
inhumePrm.SetTombstoneAddress(oidtest.Address())
|
||||
_, 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) {
|
||||
|
@ -97,9 +99,11 @@ func TestDB_Lock(t *testing.T) {
|
|||
objAddr := objectcore.AddressOf(objs[0])
|
||||
lockAddr := objectcore.AddressOf(lockObj)
|
||||
|
||||
var objLockedErr *apistatus.ObjectLocked
|
||||
|
||||
// try to inhume locked object using tombstone
|
||||
err := metaInhume(db, objAddr, lockAddr)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
require.ErrorAs(t, err, &objLockedErr)
|
||||
|
||||
// free locked object
|
||||
var inhumePrm meta.InhumePrm
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
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-observability/tracing"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"go.uber.org/zap"
|
||||
|
@ -195,7 +196,7 @@ func (s *Shard) refillMetabase(ctx context.Context) error {
|
|||
mPrm.SetStorageID(descriptor)
|
||||
|
||||
_, 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
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
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/util/logger"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
|
@ -170,7 +171,7 @@ func TestRefillMetabaseCorrupted(t *testing.T) {
|
|||
var getPrm GetPrm
|
||||
getPrm.SetAddress(addr)
|
||||
_, err = sh.Get(context.Background(), getPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, client.IsErrObjectNotFound(err))
|
||||
require.NoError(t, sh.Close())
|
||||
}
|
||||
|
||||
|
@ -297,7 +298,7 @@ func TestRefillMetabase(t *testing.T) {
|
|||
res, err := sh.Head(context.Background(), headPrm)
|
||||
|
||||
if expObj == nil {
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, client.IsErrObjectNotFound(err))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -322,9 +323,9 @@ func TestRefillMetabase(t *testing.T) {
|
|||
_, err := sh.Head(context.Background(), headPrm)
|
||||
|
||||
if exists {
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
require.True(t, client.IsErrObjectAlreadyRemoved(err))
|
||||
} 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
|
||||
prm.MarkAsGarbage(addr)
|
||||
|
||||
var target *apistatus.ObjectLocked
|
||||
_, err := sh.Inhume(context.Background(), prm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked),
|
||||
"object %s should be locked", locked[i])
|
||||
require.ErrorAs(t, err, &target, "object %s should be locked", locked[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
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-observability/tracing"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"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) {
|
||||
if s.hasWriteCache() {
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"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/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"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -57,7 +57,7 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
|
|||
require.NoError(t, err)
|
||||
|
||||
_, 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) {
|
||||
|
@ -81,6 +81,6 @@ func testShardDelete(t *testing.T, hasWriteCache bool) {
|
|||
require.NoError(t, err)
|
||||
|
||||
_, 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")
|
||||
|
||||
// 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
|
||||
// corresponds to exceeding the object bounds.
|
||||
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
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
"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/logger"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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")
|
||||
_, err = sh.Get(context.Background(), getPrm)
|
||||
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
|
||||
var metaStIDPrm meta.StorageIDPrm
|
||||
|
@ -140,5 +141,5 @@ func Test_ObjectNotFoundIfNotDeletedFromMetabase(t *testing.T) {
|
|||
//get should return object not found
|
||||
_, err = sh.Get(context.Background(), getPrm)
|
||||
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"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||
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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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))
|
||||
require.Eventually(t, func() bool {
|
||||
_, 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")
|
||||
}
|
||||
|
||||
|
@ -171,6 +172,6 @@ func Test_GCDropsLockedExpiredComplexObject(t *testing.T) {
|
|||
|
||||
require.Eventually(t, func() bool {
|
||||
_, 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")
|
||||
}
|
||||
|
|
|
@ -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/writecache"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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() {
|
||||
return nil, false, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return nil, false, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
return res, false, err
|
||||
}
|
||||
if IsErrNotFound(err) {
|
||||
if client.IsErrObjectNotFound(err) {
|
||||
s.log.Debug(logs.ShardObjectIsMissingInWritecache,
|
||||
zap.Stringer("addr", addr),
|
||||
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/local_object_storage/internal/testutil"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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)
|
||||
if hasWriteCache {
|
||||
require.Eventually(t, func() bool {
|
||||
if shard.IsErrNotFound(err) {
|
||||
if client.IsErrObjectNotFound(err) {
|
||||
res, err = sh.Get(context.Background(), getPrm)
|
||||
}
|
||||
return !shard.IsErrNotFound(err)
|
||||
return !client.IsErrObjectNotFound(err)
|
||||
}, time.Second, time.Millisecond*100)
|
||||
}
|
||||
return res, err
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"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/shard"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"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)
|
||||
if hasWriteCache {
|
||||
require.Eventually(t, func() bool {
|
||||
if shard.IsErrNotFound(err) {
|
||||
if client.IsErrObjectNotFound(err) {
|
||||
res, err = sh.Head(context.Background(), headPrm)
|
||||
}
|
||||
return !shard.IsErrNotFound(err)
|
||||
return !client.IsErrObjectNotFound(err)
|
||||
}, time.Second, time.Millisecond*100)
|
||||
}
|
||||
return res, err
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"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/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"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -56,5 +56,5 @@ func testShardInhume(t *testing.T, hasWriteCache bool) {
|
|||
require.NoError(t, err)
|
||||
|
||||
_, 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"
|
||||
"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-sdk-go/client"
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
|
@ -96,12 +97,14 @@ func TestShard_Lock(t *testing.T) {
|
|||
var inhumePrm shard.InhumePrm
|
||||
inhumePrm.SetTarget(objectcore.AddressOf(ts), objectcore.AddressOf(obj))
|
||||
|
||||
var objLockedErr *apistatus.ObjectLocked
|
||||
|
||||
_, err = sh.Inhume(context.Background(), inhumePrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectLocked))
|
||||
require.ErrorAs(t, err, &objLockedErr)
|
||||
|
||||
inhumePrm.MarkAsGarbage(objectcore.AddressOf(obj))
|
||||
_, 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) {
|
||||
|
@ -141,7 +144,7 @@ func TestShard_Lock(t *testing.T) {
|
|||
getPrm.SetAddress(objectcore.AddressOf(obj))
|
||||
|
||||
_, 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
|
||||
to := from + prm.ln
|
||||
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()
|
||||
|
|
|
@ -119,7 +119,8 @@ func testShardGetRange(t *testing.T, hasWriteCache bool) {
|
|||
|
||||
res, err := sh.GetRange(context.Background(), rngPrm)
|
||||
if tc.hasErr {
|
||||
require.ErrorAs(t, err, &apistatus.ObjectOutOfRange{})
|
||||
var target *apistatus.ObjectOutOfRange
|
||||
require.ErrorAs(t, err, &target)
|
||||
} else {
|
||||
require.Equal(t,
|
||||
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))
|
||||
if err != nil {
|
||||
if err == badger.ErrKeyNotFound {
|
||||
return logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ func (c *cache) getInternal(addr oid.Address) (*objectSDK.Object, error) {
|
|||
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.
|
||||
|
@ -79,7 +79,7 @@ func Get(db *badger.DB, key []byte) ([]byte, error) {
|
|||
it, err := tx.Get(key)
|
||||
if err != nil {
|
||||
if err == badger.ErrKeyNotFound {
|
||||
return logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
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})
|
||||
if err != nil {
|
||||
return nil, logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return nil, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
|
||||
found = true
|
||||
|
@ -93,7 +93,7 @@ func Get(db *bbolt.DB, key []byte) ([]byte, error) {
|
|||
}
|
||||
value = b.Get(key)
|
||||
if value == nil {
|
||||
return logicerr.Wrap(apistatus.ObjectNotFound{})
|
||||
return logicerr.Wrap(new(apistatus.ObjectNotFound))
|
||||
}
|
||||
value = slice.Copy(value)
|
||||
return nil
|
||||
|
|
|
@ -2,7 +2,6 @@ package writecachebbolt
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
|
@ -12,7 +11,7 @@ import (
|
|||
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/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"
|
||||
"go.etcd.io/bbolt"
|
||||
"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})
|
||||
if err != nil && !errors.As(err, new(apistatus.ObjectNotFound)) {
|
||||
if err != nil && !client.IsErrObjectNotFound(err) {
|
||||
c.log.Error(logs.WritecacheCantRemoveObjectFromWritecache, zap.Error(err))
|
||||
|
||||
// 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,
|
||||
// since unsigned table cannot be approved in the storage by design.
|
||||
if len(sig) == 0 {
|
||||
var errEACLNotFound apistatus.EACLNotFound
|
||||
|
||||
return nil, errEACLNotFound
|
||||
return nil, new(apistatus.EACLNotFound)
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), containerContract.NotFoundError) {
|
||||
var errNotFound apistatus.ContainerNotFound
|
||||
|
||||
return nil, errNotFound
|
||||
return nil, new(apistatus.ContainerNotFound)
|
||||
}
|
||||
return nil, fmt.Errorf("could not perform test invocation (%s): %w", getMethod, err)
|
||||
} 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")
|
||||
}
|
||||
if req.token.ExpiredAt(currentEpoch) {
|
||||
return info, apistatus.SessionTokenExpired{}
|
||||
return info, new(apistatus.SessionTokenExpired)
|
||||
}
|
||||
if req.token.InvalidAt(currentEpoch) {
|
||||
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
|
||||
}
|
||||
|
||||
var errMaintenance apistatus.NodeUnderMaintenance
|
||||
|
||||
func (x *Common) Get(req *objectV2.GetRequest, stream GetObjectStream) error {
|
||||
if x.state.IsMaintenance() {
|
||||
return errMaintenance
|
||||
return new(apistatus.NodeUnderMaintenance)
|
||||
}
|
||||
|
||||
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) {
|
||||
if x.state.IsMaintenance() {
|
||||
return nil, errMaintenance
|
||||
return nil, new(apistatus.NodeUnderMaintenance)
|
||||
}
|
||||
|
||||
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) {
|
||||
if x.state.IsMaintenance() {
|
||||
return nil, errMaintenance
|
||||
return nil, new(apistatus.NodeUnderMaintenance)
|
||||
}
|
||||
|
||||
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 {
|
||||
if x.state.IsMaintenance() {
|
||||
return errMaintenance
|
||||
return new(apistatus.NodeUnderMaintenance)
|
||||
}
|
||||
|
||||
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) {
|
||||
if x.state.IsMaintenance() {
|
||||
return nil, errMaintenance
|
||||
return nil, new(apistatus.NodeUnderMaintenance)
|
||||
}
|
||||
|
||||
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 {
|
||||
if x.state.IsMaintenance() {
|
||||
return errMaintenance
|
||||
return new(apistatus.NodeUnderMaintenance)
|
||||
}
|
||||
|
||||
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) {
|
||||
if x.state.IsMaintenance() {
|
||||
return nil, errMaintenance
|
||||
return nil, new(apistatus.NodeUnderMaintenance)
|
||||
}
|
||||
|
||||
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) {
|
||||
if x.state.IsMaintenance() {
|
||||
return nil, errMaintenance
|
||||
return nil, new(apistatus.NodeUnderMaintenance)
|
||||
}
|
||||
|
||||
return x.nextHandler.PutSingle(ctx, req)
|
||||
|
|
|
@ -63,8 +63,8 @@ func (r *request) assemble(ctx context.Context) {
|
|||
var errSplitInfo *objectSDK.SplitInfoError
|
||||
var errRemovedRemote *apistatus.ObjectAlreadyRemoved
|
||||
var errOutOfRangeRemote *apistatus.ObjectOutOfRange
|
||||
var errRemovedLocal apistatus.ObjectAlreadyRemoved
|
||||
var errOutOfRangeLocal apistatus.ObjectOutOfRange
|
||||
var errRemovedLocal *apistatus.ObjectAlreadyRemoved
|
||||
var errOutOfRangeLocal *apistatus.ObjectOutOfRange
|
||||
|
||||
switch {
|
||||
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_manager/placement"
|
||||
"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"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||
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) {
|
||||
v, ok := c.results[address.EncodeToString()]
|
||||
if !ok {
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
return nil, errNotFound
|
||||
return nil, new(apistatus.ObjectNotFound)
|
||||
}
|
||||
|
||||
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 {
|
||||
var errRemoved apistatus.ObjectAlreadyRemoved
|
||||
|
||||
return nil, errRemoved
|
||||
return nil, new(apistatus.ObjectAlreadyRemoved)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
return nil, errNotFound
|
||||
return nil, new(apistatus.ObjectNotFound)
|
||||
}
|
||||
|
||||
func cutToRange(o *objectSDK.Object, rng *objectSDK.Range) *objectSDK.Object {
|
||||
|
@ -374,19 +369,19 @@ func TestGetLocalOnly(t *testing.T) {
|
|||
|
||||
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.WithAddress(addr)
|
||||
|
||||
err = svc.GetRange(ctx, rngPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectAlreadyRemoved))
|
||||
require.True(t, clientSDK.IsErrObjectAlreadyRemoved(err))
|
||||
|
||||
headPrm := newHeadPrm(false, nil)
|
||||
headPrm.WithAddress(addr)
|
||||
|
||||
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) {
|
||||
|
@ -401,20 +396,20 @@ func TestGetLocalOnly(t *testing.T) {
|
|||
|
||||
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.WithAddress(addr)
|
||||
|
||||
err = svc.GetRange(ctx, rngPrm)
|
||||
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||
|
||||
headPrm := newHeadPrm(false, nil)
|
||||
headPrm.WithAddress(addr)
|
||||
|
||||
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) {
|
||||
|
@ -679,19 +674,19 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
p.WithAddress(addr)
|
||||
|
||||
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.WithAddress(addr)
|
||||
|
||||
err = svc.GetRange(ctx, rngPrm)
|
||||
require.ErrorAs(t, err, new(*apistatus.ObjectAlreadyRemoved))
|
||||
require.True(t, clientSDK.IsErrObjectAlreadyRemoved(err))
|
||||
|
||||
headPrm := newHeadPrm(false, nil)
|
||||
headPrm.WithAddress(addr)
|
||||
|
||||
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) {
|
||||
|
@ -723,19 +718,19 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
p.WithAddress(addr)
|
||||
|
||||
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.WithAddress(addr)
|
||||
|
||||
err = svc.GetRange(ctx, rngPrm)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||
|
||||
headPrm := newHeadPrm(false, nil)
|
||||
headPrm.WithAddress(addr)
|
||||
|
||||
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) {
|
||||
|
@ -768,11 +763,11 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
|
||||
c1 := newTestClient()
|
||||
c1.addResult(addr, nil, errors.New("any error"))
|
||||
c1.addResult(splitAddr, nil, apistatus.ObjectNotFound{})
|
||||
c1.addResult(splitAddr, nil, new(apistatus.ObjectNotFound))
|
||||
|
||||
c2 := newTestClient()
|
||||
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
||||
c2.addResult(splitAddr, nil, apistatus.ObjectNotFound{})
|
||||
c2.addResult(splitAddr, nil, new(apistatus.ObjectNotFound))
|
||||
|
||||
builder := &testPlacementBuilder{
|
||||
vectors: map[string][][]netmap.NodeInfo{
|
||||
|
@ -794,13 +789,13 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
p.WithAddress(addr)
|
||||
|
||||
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.WithAddress(addr)
|
||||
|
||||
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) {
|
||||
|
@ -845,7 +840,7 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
||||
c2.addResult(linkAddr, linkingObj, nil)
|
||||
c2.addResult(child1Addr, children[0], nil)
|
||||
c2.addResult(child2Addr, nil, apistatus.ObjectNotFound{})
|
||||
c2.addResult(child2Addr, nil, new(apistatus.ObjectNotFound))
|
||||
|
||||
builder := &testPlacementBuilder{
|
||||
vectors: map[string][][]netmap.NodeInfo{
|
||||
|
@ -869,13 +864,13 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
p.WithAddress(addr)
|
||||
|
||||
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.WithAddress(addr)
|
||||
|
||||
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) {
|
||||
|
@ -1315,11 +1310,11 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
|
||||
c1 := newTestClient()
|
||||
c1.addResult(addr, nil, errors.New("any error"))
|
||||
c1.addResult(splitAddr, nil, apistatus.ObjectNotFound{})
|
||||
c1.addResult(splitAddr, nil, new(apistatus.ObjectNotFound))
|
||||
|
||||
c2 := newTestClient()
|
||||
c2.addResult(addr, nil, objectSDK.NewSplitInfoError(splitInfo))
|
||||
c2.addResult(splitAddr, nil, apistatus.ObjectNotFound{})
|
||||
c2.addResult(splitAddr, nil, new(apistatus.ObjectNotFound))
|
||||
|
||||
builder := &testPlacementBuilder{
|
||||
vectors: map[string][][]netmap.NodeInfo{
|
||||
|
@ -1341,13 +1336,13 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
p.WithAddress(addr)
|
||||
|
||||
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.WithAddress(addr)
|
||||
|
||||
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) {
|
||||
|
@ -1403,19 +1398,19 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
testHeadVirtual(svc, addr, splitInfo)
|
||||
|
||||
headSvc := newTestClient()
|
||||
headSvc.addResult(preRightAddr, nil, apistatus.ObjectNotFound{})
|
||||
headSvc.addResult(preRightAddr, nil, new(apistatus.ObjectNotFound))
|
||||
|
||||
p := newPrm(false, NewSimpleObjectWriter())
|
||||
p.WithAddress(addr)
|
||||
|
||||
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.WithAddress(addr)
|
||||
|
||||
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) {
|
||||
|
@ -1711,7 +1706,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
|||
p.WithAddress(addr)
|
||||
|
||||
err := svc.Get(ctx, p)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||
|
||||
commonPrm.SetNetmapLookupDepth(1)
|
||||
|
||||
|
@ -1734,7 +1729,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
|||
rp.SetRange(r)
|
||||
|
||||
err = svc.GetRange(ctx, rp)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||
|
||||
w = NewSimpleObjectWriter()
|
||||
rp.SetChunkWriter(w)
|
||||
|
@ -1751,7 +1746,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
|||
hp.WithAddress(addr)
|
||||
|
||||
err = svc.Head(ctx, hp)
|
||||
require.ErrorAs(t, err, new(apistatus.ObjectNotFound))
|
||||
require.True(t, clientSDK.IsErrObjectNotFound(err))
|
||||
|
||||
w = NewSimpleObjectWriter()
|
||||
hp.SetHeaderWriter(w)
|
||||
|
|
|
@ -22,8 +22,8 @@ func (r *request) executeLocal(ctx context.Context) {
|
|||
r.collectedObject, err = r.get(ctx)
|
||||
|
||||
var errSplitInfo *objectSDK.SplitInfoError
|
||||
var errRemoved apistatus.ObjectAlreadyRemoved
|
||||
var errOutOfRange apistatus.ObjectOutOfRange
|
||||
var errRemoved *apistatus.ObjectAlreadyRemoved
|
||||
var errOutOfRange *apistatus.ObjectOutOfRange
|
||||
|
||||
switch {
|
||||
default:
|
||||
|
|
|
@ -31,10 +31,8 @@ func (r *request) processNode(ctx context.Context, info client.NodeInfo) bool {
|
|||
|
||||
switch {
|
||||
default:
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
r.status = statusUndefined
|
||||
r.err = errNotFound
|
||||
r.err = new(apistatus.ObjectNotFound)
|
||||
|
||||
r.log.Debug(logs.GetRemoteCallFailed, zap.Error(err))
|
||||
case err == nil:
|
||||
|
|
|
@ -3,7 +3,6 @@ package getsvc
|
|||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"hash"
|
||||
|
||||
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"
|
||||
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
||||
"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"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
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(),
|
||||
Owner: tok.Issuer(),
|
||||
})
|
||||
if err != nil && errors.As(err, new(apistatus.SessionTokenNotFound)) {
|
||||
if err != nil && clientSDK.IsErrSessionNotFound(err) {
|
||||
commonPrm.ForgetTokens()
|
||||
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)
|
||||
if pToken != nil {
|
||||
if pToken.ExpiredAt() <= s.networkState.CurrentEpoch() {
|
||||
var errExpired apistatus.SessionTokenExpired
|
||||
|
||||
return nil, errExpired
|
||||
return nil, new(apistatus.SessionTokenExpired)
|
||||
}
|
||||
return pToken.SessionKey(), nil
|
||||
}
|
||||
|
||||
var errNotFound apistatus.SessionTokenNotFound
|
||||
|
||||
return nil, errNotFound
|
||||
return nil, new(apistatus.SessionTokenNotFound)
|
||||
}
|
||||
|
||||
return s.key, nil
|
||||
|
|
|
@ -2,12 +2,11 @@ package tsourse
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
||||
"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"
|
||||
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)
|
||||
switch {
|
||||
case errors.As(err, new(apistatus.ObjectNotFound)) || errors.As(err, new(apistatus.ObjectAlreadyRemoved)):
|
||||
case client.IsErrObjectNotFound(err) || client.IsErrObjectAlreadyRemoved(err):
|
||||
return nil, nil
|
||||
case err != nil:
|
||||
return nil, fmt.Errorf("could not get tombstone from the source: %w", err)
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
|
||||
"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"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/replicator"
|
||||
"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.String("error", err.Error()),
|
||||
)
|
||||
if container.IsErrNotFound(err) {
|
||||
if client.IsErrContainerNotFound(err) {
|
||||
err := p.buryFn(ctx, addrWithType.Address)
|
||||
if err != nil {
|
||||
p.log.Error(logs.PolicerCouldNotInhumeObjectWithMissingContainer,
|
||||
|
@ -218,7 +217,6 @@ func isClientErrMaintenance(err error) bool {
|
|||
default:
|
||||
return false
|
||||
case
|
||||
apistatus.NodeUnderMaintenance,
|
||||
*apistatus.NodeUnderMaintenance:
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestBuryObjectWithoutContainer(t *testing.T) {
|
|||
// Container source and bury function
|
||||
buryCh := make(chan oid.Address)
|
||||
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 {
|
||||
buryCh <- a
|
||||
|
@ -187,7 +187,7 @@ func TestProcessObject(t *testing.T) {
|
|||
return nil, nil
|
||||
}
|
||||
}
|
||||
return nil, apistatus.ObjectNotFound{}
|
||||
return nil, new(apistatus.ObjectNotFound)
|
||||
}
|
||||
|
||||
// Container source
|
||||
|
@ -199,7 +199,7 @@ func TestProcessObject(t *testing.T) {
|
|||
return cnr, nil
|
||||
}
|
||||
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 {
|
||||
t.Errorf("unexpected object buried: %v", a)
|
||||
|
@ -252,7 +252,7 @@ func TestIteratorContract(t *testing.T) {
|
|||
}}
|
||||
|
||||
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 {
|
||||
return nil
|
||||
|
|
|
@ -51,7 +51,7 @@ func (s *SignService) SignResponse(resp ResponseMessage, err error) error {
|
|||
|
||||
func (s *SignService) VerifyRequest(req RequestMessage) error {
|
||||
if err := signature.VerifyServiceMessage(req); err != nil {
|
||||
var sigErr apistatus.SignatureVerification
|
||||
sigErr := new(apistatus.SignatureVerification)
|
||||
sigErr.SetMessage(err.Error())
|
||||
return sigErr
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue