From c2918fce3a1aa95c9b4aad4f757c8257b4049dc2 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Mon, 1 Aug 2022 18:28:40 +0300 Subject: [PATCH] [#1645] node: Support `EACL_NOT_FOUND` status Remove internal `ErrEACLNotFound` error. Also, update `neofs-api-go` and `neofs-sdk-go` libraries. Signed-off-by: Pavel Karpy --- pkg/core/container/storage.go | 4 ---- pkg/morph/client/container/eacl.go | 7 ++++++- pkg/services/object/acl/acl.go | 4 ++-- pkg/services/object/acl/eacl/types.go | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/core/container/storage.go b/pkg/core/container/storage.go index 7babe9bf92..18478c3155 100644 --- a/pkg/core/container/storage.go +++ b/pkg/core/container/storage.go @@ -43,10 +43,6 @@ func IsErrNotFound(err error) bool { return errors.As(err, new(apistatus.ContainerNotFound)) } -// ErrEACLNotFound is returned by eACL storage implementations when -// the requested eACL table is not in the storage. -var ErrEACLNotFound = errors.New("extended ACL table is not set for this container") - // EACL groups information about the NeoFS container's extended ACL stored in // the NeoFS network. type EACL struct { diff --git a/pkg/morph/client/container/eacl.go b/pkg/morph/client/container/eacl.go index c65c0cffc2..dfb04c3ef4 100644 --- a/pkg/morph/client/container/eacl.go +++ b/pkg/morph/client/container/eacl.go @@ -7,6 +7,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/morph/client" + apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" "github.com/nspcc-dev/neofs-sdk-go/eacl" "github.com/nspcc-dev/neofs-sdk-go/session" @@ -14,6 +15,8 @@ import ( // GetEACL reads the extended ACL table from NeoFS system // through Container contract call. +// +// Returns apistatus.EACLNotFound if eACL table is missing in the contract. func (c *Client) GetEACL(cnr cid.ID) (*container.EACL, error) { binCnr := make([]byte, sha256.Size) cnr.Encode(binCnr) @@ -52,7 +55,9 @@ func (c *Client) GetEACL(cnr cid.ID) (*container.EACL, error) { // The absence of a signature in the response can be taken as an eACL absence criterion, // since unsigned table cannot be approved in the storage by design. if len(sig) == 0 { - return nil, container.ErrEACLNotFound + var errEACLNotFound apistatus.EACLNotFound + + return nil, errEACLNotFound } pub, err := client.BytesFromStackItem(arr[2]) diff --git a/pkg/services/object/acl/acl.go b/pkg/services/object/acl/acl.go index 370c250ed7..2c8793cdd8 100644 --- a/pkg/services/object/acl/acl.go +++ b/pkg/services/object/acl/acl.go @@ -7,13 +7,13 @@ import ( "fmt" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" - "github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl" eaclV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl/v2" v2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/v2" bearerSDK "github.com/nspcc-dev/neofs-sdk-go/bearer" + "github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/container/acl" neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa" eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl" @@ -136,7 +136,7 @@ func (c *Checker) CheckEACL(msg interface{}, reqInfo v2.RequestInfo) error { if bearerTok == nil { eaclInfo, err := c.eaclSrc.GetEACL(cnr) if err != nil { - if errors.Is(err, container.ErrEACLNotFound) { + if client.IsErrEACLNotFound(err) { return nil } return err diff --git a/pkg/services/object/acl/eacl/types.go b/pkg/services/object/acl/eacl/types.go index 0f3a836b36..4abd992d26 100644 --- a/pkg/services/object/acl/eacl/types.go +++ b/pkg/services/object/acl/eacl/types.go @@ -13,7 +13,7 @@ type Source interface { // // GetEACL must return exactly one non-nil value. // - // Must return pkg/core/container.ErrEACLNotFound if requested + // Must return apistatus.ErrEACLNotFound if requested // eACL table is not in source. GetEACL(cid.ID) (*containercore.EACL, error) }