Skip to content

Commit

Permalink
Handle client errors according to NeoFS SDK RC-9 (#2468)
Browse files Browse the repository at this point in the history
  • Loading branch information
cthulhu-rider authored Aug 8, 2023
2 parents 4a0198f + 5387290 commit d67d5d3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Changelog for NeoFS Node
- Session inactivity on object PUT request relay (#2460)
- Missing connection retries on IR node startup when the first configured mainnet RPC node is not in sync (#2474)
- Storage node no longer ignores unhealthy shards on startup (#2464)
- Processing of status errors returned by API client from NeoFS SDK RC-9 (#2465)

### Removed
- Deprecated `morph.rpc_endpoint` SN and `morph.endpoint.client` IR config sections (#2400)
Expand Down
10 changes: 3 additions & 7 deletions cmd/neofs-cli/internal/common/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ func ExitOnErr(cmd *cobra.Command, errFmt string, err error) {
aclDenied
)

var (
code int

internalErr = new(sdkstatus.ServerInternal)
accessErr = new(sdkstatus.ObjectAccessDenied)
)
var code int
var accessErr = new(sdkstatus.ObjectAccessDenied)

switch {
case errors.As(err, &internalErr):
case errors.Is(err, sdkstatus.ErrServerInternal):
code = internal
case errors.As(err, &accessErr):
code = aclDenied
Expand Down
14 changes: 5 additions & 9 deletions pkg/services/object/get/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ func (exec *execCtx) processNode(ctx context.Context, info client.NodeInfo) bool
obj, err := client.getObject(exec, info)

var errSplitInfo *objectSDK.SplitInfoError
var errRemoved *apistatus.ObjectAlreadyRemoved
var errOutOfRange *apistatus.ObjectOutOfRange

switch {
default:
var errNotFound apistatus.ObjectNotFound

exec.status = statusUndefined
exec.err = errNotFound
exec.err = apistatus.ErrObjectNotFound

exec.log.Debug("remote call failed",
zap.String("error", err.Error()),
Expand All @@ -45,12 +41,12 @@ func (exec *execCtx) processNode(ctx context.Context, info client.NodeInfo) bool
exec.collectedObject = obj
exec.writeCollectedObject()
}
case errors.As(err, &errRemoved):
case errors.Is(err, apistatus.ErrObjectAlreadyRemoved):
exec.status = statusINHUMED
exec.err = errRemoved
case errors.As(err, &errOutOfRange):
exec.err = err
case errors.Is(err, apistatus.ErrObjectOutOfRange):
exec.status = statusOutOfRange
exec.err = errOutOfRange
exec.err = err
case errors.As(err, &errSplitInfo):
exec.status = statusVIRTUAL
mergeSplitInfo(exec.splitInfo(), errSplitInfo.SplitInfo())
Expand Down
3 changes: 1 addition & 2 deletions pkg/services/object/get/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ func (c *clientWrapper) getObject(exec *execCtx, info coreclient.NodeInfo) (*obj

res, err := internalclient.PayloadRange(prm)
if err != nil {
var errAccessDenied *apistatus.ObjectAccessDenied
if errors.As(err, &errAccessDenied) {
if errors.Is(err, apistatus.ErrObjectAccessDenied) {
// Current spec allows other storage node to deny access,
// fallback to GET here.
obj, err := c.get(exec, key)
Expand Down
4 changes: 3 additions & 1 deletion pkg/services/object/head/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func (p *RemoteHeadPrm) WithObjectAddress(v oid.Address) *RemoteHeadPrm {
return p
}

// Head requests object header from the remote node.
// Head requests object header from the remote node. Returns:
// - [apistatus.ErrObjectNotFound] error if the requested object is missing
// - [apistatus.ErrNodeUnderMaintenance] error if remote node is currently under maintenance
func (h *RemoteHeader) Head(ctx context.Context, prm *RemoteHeadPrm) (*object.Object, error) {
key, err := h.keyStorage.GetKey(nil)
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions pkg/services/object/internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func (x GetObjectRes) Object() *object.Object {
//
// Returns any error which prevented the operation from completing correctly in error return.
// Returns:
// - error of type *object.SplitInfoError if object raw flag is set and requested object is virtual;
// - error of type *apistatus.ObjectAlreadyRemoved if the requested object is marked to be removed.
// - error of type *object.SplitInfoError if object raw flag is set and requested object is virtual
// - [apistatus.ErrObjectAlreadyRemoved] error if the requested object is marked to be removed
//
// GetObject ignores the provided session if it is not related to the requested object.
func GetObject(prm GetObjectPrm) (*GetObjectRes, error) {
Expand Down Expand Up @@ -228,9 +228,9 @@ func (x HeadObjectRes) Header() *object.Object {
//
// Returns any error which prevented the operation from completing correctly in error return.
// Returns:
//
// error of type *object.SplitInfoError if object raw flag is set and requested object is virtual;
// error of type *apistatus.ObjectAlreadyRemoved if the requested object is marked to be removed.
// - error of type *object.SplitInfoError if object raw flag is set and requested object is virtual
// - [apistatus.ErrObjectAlreadyRemoved] error if the requested object is marked to be removed
// - [apistatus.ErrNodeUnderMaintenance] error if remote node is currently under maintenance
//
// HeadObject ignores the provided session if it is not related to the requested object.
func HeadObject(prm HeadObjectPrm) (*HeadObjectRes, error) {
Expand Down Expand Up @@ -321,10 +321,10 @@ const maxInitialBufferSize = 1024 * 1024 // 1 MiB
//
// Returns any error which prevented the operation from completing correctly in error return.
// Returns:
//
// error of type *object.SplitInfoError if object raw flag is set and requested object is virtual;
// error of type *apistatus.ObjectAlreadyRemoved if the requested object is marked to be removed;
// error of type *apistatus.ObjectOutOfRange if the requested range is too big.
// - error of type *object.SplitInfoError if object raw flag is set and requested object is virtual
// - [apistatus.ErrObjectAlreadyRemoved] error if the requested object is marked to be removed
// - [apistatus.ErrObjectOutOfRange] error if the requested range is too big
// - [apistatus.ErrObjectAccessDenied] error if access to the requested object is denied
//
// PayloadRange ignores the provided session if it is not related to the requested object.
func PayloadRange(prm PayloadRangePrm) (*PayloadRangeRes, error) {
Expand Down

0 comments on commit d67d5d3

Please sign in to comment.