[#1175] shard: Return status error on Inhume of locked object

Make `Shard.Inhume` to forward `apistatus.ObjectLocked` returned by
underlying metabase.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-02-16 01:19:50 +03:00 committed by LeL
parent b585791d6e
commit e21eedee06

View file

@ -1,6 +1,8 @@
package shard
import (
"fmt"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
"go.uber.org/zap"
@ -44,6 +46,9 @@ func (p *InhumePrm) MarkAsGarbage(addr ...*addressSDK.Address) *InhumePrm {
// Inhume calls metabase. Inhume method to mark object as removed. It won't be
// removed physically from blobStor and metabase until `Delete` operation.
//
// Allows inhuming non-locked objects only. Returns apistatus.ObjectLocked
// if at least one object is locked.
//
// Returns ErrReadOnlyMode error if shard is in "read-only" mode.
func (s *Shard) Inhume(prm *InhumePrm) (*InhumeRes, error) {
if s.GetMode() == ModeReadOnly {
@ -69,6 +74,8 @@ func (s *Shard) Inhume(prm *InhumePrm) (*InhumeRes, error) {
s.log.Debug("could not mark object to delete in metabase",
zap.String("error", err.Error()),
)
return nil, fmt.Errorf("metabase inhume: %w", err)
}
return new(InhumeRes), nil