Skip to content

Commit ff7d5b5

Browse files
committed
sn/container: Support CONTAINER_LOCKED status
Catch 'container is locked' exception added in nspcc-dev/neofs-contract#558 and respond with `CONTAINER_LOCKED` API status on it. Signed-off-by: Leonard Lyubich <[email protected]>
1 parent ff1db20 commit ff7d5b5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Changelog for NeoFS Node
1212
- CLI supports `CONTAINER_AWAIT_TIMEOUT` status now (#3711)
1313
- Policer logs when it reaches the end of its cycle (#3720)
1414
- Containers can now be locked for deletion via `__NEOFS__LOCK_UNTIL` attribute (#3708)
15+
- SN can respond with `CONTAINER_LOCKED` status now (#3708)
1516

1617
### Fixed
1718
- IR panics at graceful shutdown (#3706)

pkg/morph/client/container/delete.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ package container
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

8+
containerrpc "github.com/nspcc-dev/neofs-contract/rpc/container"
79
fschaincontracts "github.com/nspcc-dev/neofs-node/pkg/morph/contracts"
10+
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
811
)
912

1013
// DeletePrm groups parameters of Delete client operation.
@@ -42,6 +45,8 @@ func (d *DeletePrm) SetToken(token []byte) {
4245
//
4346
// Returns any error encountered that caused
4447
// the removal to interrupt.
48+
//
49+
// Returns [apistatus.ContainerLocked] if container is locked.
4550
func (c *Client) Delete(ctx context.Context, p DeletePrm) error {
4651
if len(p.signature) == 0 {
4752
return errNilArgument
@@ -56,10 +61,16 @@ func (c *Client) Delete(ctx context.Context, p DeletePrm) error {
5661
p.cnr, p.signature, p.key, p.token,
5762
})
5863
if err != nil {
64+
if e := err.Error(); strings.Contains(e, containerrpc.ErrorLocked) {
65+
return apistatus.NewContainerLocked(e)
66+
}
5967
return fmt.Errorf("could not invoke method (%s): %w", deleteMethod, err)
6068
}
6169
return nil
6270
}
71+
if e := err.Error(); strings.Contains(e, containerrpc.ErrorLocked) {
72+
return apistatus.NewContainerLocked(e)
73+
}
6374
return fmt.Errorf("could not invoke method (%s): %w", fschaincontracts.RemoveContainerMethod, err)
6475
}
6576
return nil

0 commit comments

Comments
 (0)