diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b060a9daa0..f6384a82753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Changelog for NeoFS Node ### Changed - CLI `--timeout` flag configures whole execution timeout from now (#2124) - CLI default timeout for commands with `--await` flag increased to 1m (#2124) +- BlobStor tries to store object in any sub-storage with free space (#2450) ### Updated - `neofs-sdk-go` to `v1.0.0-rc.9` diff --git a/pkg/local_object_storage/blobstor/put.go b/pkg/local_object_storage/blobstor/put.go index 044c41bbf75..ba86dbb089c 100644 --- a/pkg/local_object_storage/blobstor/put.go +++ b/pkg/local_object_storage/blobstor/put.go @@ -44,7 +44,7 @@ func (b *BlobStor) Put(prm common.PutPrm) (common.PutRes, error) { res, err := b.storage[i].Storage.Put(prm) if err == nil { logOp(b.log, putOp, prm.Address, b.storage[i].Storage.Type(), res.StorageID) - } else if errors.Is(err, common.ErrNoSpace) { + } else if errors.Is(err, common.ErrNoSpace) && i < len(b.storage)-1 { b.log.Debug("blobstor sub-storage overflowed, will try another one", zap.String("type", b.storage[i].Storage.Type())) continue diff --git a/pkg/local_object_storage/blobstor/put_test.go b/pkg/local_object_storage/blobstor/put_test.go index 9d75bf893fe..3c991fea097 100644 --- a/pkg/local_object_storage/blobstor/put_test.go +++ b/pkg/local_object_storage/blobstor/put_test.go @@ -31,13 +31,20 @@ func (x *mockWriter) Put(common.PutPrm) (common.PutRes, error) { func (x *mockWriter) SetCompressor(*compression.Config) {} func TestBlobStor_Put_Overflow(t *testing.T) { + sub1 := &mockWriter{full: true} + sub2 := &mockWriter{full: false} bs := blobstor.New(blobstor.WithStorages( []blobstor.SubStorage{ - {Storage: &mockWriter{full: true}}, - {Storage: &mockWriter{full: false}}, + {Storage: sub1}, + {Storage: sub2}, }, )) _, err := bs.Put(common.PutPrm{}) require.NoError(t, err) + + sub2.full = true + + _, err = bs.Put(common.PutPrm{}) + require.ErrorIs(t, err, common.ErrNoSpace) }