Skip to content

Commit

Permalink
blobstor: Return ErrNoSpace if all sub-storages are full
Browse files Browse the repository at this point in the history
Previously, `BlobStor` returned `ErrNoPlaceFound` when all sub-storages
were full. This error is related to policy compliance instead of free
space. To make component more responsive, the `ErrNoSpace` error should
be returned in these cases.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Jul 21, 2023
1 parent fa03442 commit 7a3896b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/blobstor/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions pkg/local_object_storage/blobstor/put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 7a3896b

Please sign in to comment.