diff --git a/pkg/local_object_storage/engine/tree.go b/pkg/local_object_storage/engine/tree.go index 43ac27f5..41576132 100644 --- a/pkg/local_object_storage/engine/tree.go +++ b/pkg/local_object_storage/engine/tree.go @@ -1,7 +1,10 @@ package engine import ( + "errors" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id" "go.uber.org/zap" ) @@ -19,6 +22,9 @@ func (e *StorageEngine) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pil zap.Stringer("cid", d.CID), zap.String("tree", treeID), zap.String("err", err.Error())) + if errors.Is(err, shard.ErrReadOnlyMode) { + return nil, err + } continue } return lm, nil @@ -37,6 +43,9 @@ func (e *StorageEngine) TreeAddByPath(d pilorama.CIDDescriptor, treeID string, a zap.Stringer("cid", d.CID), zap.String("tree", treeID), zap.String("err", err.Error())) + if errors.Is(err, shard.ErrReadOnlyMode) { + return nil, err + } continue } return lm, nil @@ -54,6 +63,9 @@ func (e *StorageEngine) TreeApply(d pilorama.CIDDescriptor, treeID string, m *pi zap.Stringer("cid", d.CID), zap.String("tree", treeID), zap.String("err", err.Error())) + if errors.Is(err, shard.ErrReadOnlyMode) { + return err + } continue } return nil diff --git a/pkg/local_object_storage/shard/tree.go b/pkg/local_object_storage/shard/tree.go index fae5e534..33f120a9 100644 --- a/pkg/local_object_storage/shard/tree.go +++ b/pkg/local_object_storage/shard/tree.go @@ -9,16 +9,25 @@ var _ pilorama.Forest = (*Shard)(nil) // TreeMove implements the pilorama.Forest interface. func (s *Shard) TreeMove(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) (*pilorama.LogMove, error) { + if s.GetMode() != ModeReadWrite { + return nil, ErrReadOnlyMode + } return s.pilorama.TreeMove(d, treeID, m) } // TreeAddByPath implements the pilorama.Forest interface. func (s *Shard) TreeAddByPath(d pilorama.CIDDescriptor, treeID string, attr string, path []string, meta []pilorama.KeyValue) ([]pilorama.LogMove, error) { + if s.GetMode() != ModeReadWrite { + return nil, ErrReadOnlyMode + } return s.pilorama.TreeAddByPath(d, treeID, attr, path, meta) } // TreeApply implements the pilorama.Forest interface. func (s *Shard) TreeApply(d pilorama.CIDDescriptor, treeID string, m *pilorama.Move) error { + if s.GetMode() != ModeReadWrite { + return ErrReadOnlyMode + } return s.pilorama.TreeApply(d, treeID, m) }