Skip to content

Commit 3f135c3

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 5913a26 commit 3f135c3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Changelog for NeoFS Node
1010
- SN tries new NEP-11 methods `tokens` and `tokensOf` of Container contract (#3701)
1111
- SN now listens to NEP-11 `transfer` events of Container contract (#3701)
1212
- IR accepts containers with `__NEOFS__LOCK_UNTIL` attribute now (#3708)
13-
- Support for `CONTAINER_LOCKED` status in CLI (#3708)
13+
- Support for `CONTAINER_LOCKED` status in CLI and SN (#3708)
1414

1515
### Fixed
1616
- 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
@@ -2,9 +2,12 @@ package container
22

33
import (
44
"fmt"
5+
"strings"
56

7+
containerrpc "github.com/nspcc-dev/neofs-contract/rpc/container"
68
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
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(p DeletePrm) error {
4651
if len(p.signature) == 0 {
4752
return errNilArgument
@@ -63,10 +68,16 @@ func (c *Client) Delete(p DeletePrm) error {
6368
prm.SetMethod(deleteMethod)
6469
prm.SetArgs(p.cnr, p.signature, p.token)
6570
if err = c.client.Invoke(prm); err != nil {
71+
if e := err.Error(); strings.Contains(e, containerrpc.ErrorLocked) {
72+
return apistatus.NewContainerLocked(e)
73+
}
6674
return fmt.Errorf("could not invoke method (%s): %w", deleteMethod, err)
6775
}
6876
return nil
6977
}
78+
if e := err.Error(); strings.Contains(e, containerrpc.ErrorLocked) {
79+
return apistatus.NewContainerLocked(e)
80+
}
7081
return fmt.Errorf("could not invoke method (%s): %w", fschaincontracts.RemoveContainerMethod, err)
7182
}
7283
return nil

0 commit comments

Comments
 (0)