forked from TrueCloudLab/frostfs-node
[#1175] storage engine: Return status error on Delete of locked object
Make `StorageEngine.Delete` to forward first encountered `apistatus.ObjectLocked` error during shard processing. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
97b6ec8150
commit
88cefa7c5f
1 changed files with 19 additions and 1 deletions
|
@ -1,7 +1,10 @@
|
||||||
package engine
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||||
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,6 +30,9 @@ func (p *DeletePrm) WithAddresses(addr ...*addressSDK.Address) *DeletePrm {
|
||||||
// Delete marks the objects to be removed.
|
// Delete marks the objects to be removed.
|
||||||
//
|
//
|
||||||
// Returns an error if executions are blocked (see BlockExecution).
|
// Returns an error if executions are blocked (see BlockExecution).
|
||||||
|
//
|
||||||
|
// Returns apistatus.ObjectLocked if at least one object is locked.
|
||||||
|
// In this case no object from the list is marked to be deleted.
|
||||||
func (e *StorageEngine) Delete(prm *DeletePrm) (res *DeleteRes, err error) {
|
func (e *StorageEngine) Delete(prm *DeletePrm) (res *DeleteRes, err error) {
|
||||||
err = e.execIfNotBlocked(func() error {
|
err = e.execIfNotBlocked(func() error {
|
||||||
res, err = e.delete(prm)
|
res, err = e.delete(prm)
|
||||||
|
@ -43,6 +49,10 @@ func (e *StorageEngine) delete(prm *DeletePrm) (*DeleteRes, error) {
|
||||||
|
|
||||||
shPrm := new(shard.InhumePrm)
|
shPrm := new(shard.InhumePrm)
|
||||||
existsPrm := new(shard.ExistsPrm)
|
existsPrm := new(shard.ExistsPrm)
|
||||||
|
var locked struct {
|
||||||
|
is bool
|
||||||
|
err apistatus.ObjectLocked
|
||||||
|
}
|
||||||
|
|
||||||
for i := range prm.addr {
|
for i := range prm.addr {
|
||||||
e.iterateOverSortedShards(prm.addr[i], func(_ int, sh hashedShard) (stop bool) {
|
e.iterateOverSortedShards(prm.addr[i], func(_ int, sh hashedShard) (stop bool) {
|
||||||
|
@ -57,11 +67,19 @@ func (e *StorageEngine) delete(prm *DeletePrm) (*DeleteRes, error) {
|
||||||
_, err = sh.Inhume(shPrm.MarkAsGarbage(prm.addr[i]))
|
_, err = sh.Inhume(shPrm.MarkAsGarbage(prm.addr[i]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.reportShardError(sh, "could not inhume object in shard", err)
|
e.reportShardError(sh, "could not inhume object in shard", err)
|
||||||
|
|
||||||
|
locked.is = errors.As(err, &locked.err)
|
||||||
|
|
||||||
|
return locked.is
|
||||||
}
|
}
|
||||||
|
|
||||||
return err == nil
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if locked.is {
|
||||||
|
return nil, locked.err
|
||||||
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue