[#1590] node: Check status of forwarded requests
After fixing version fields in forwarded requests, a node does not check statuses since errors are not covered by direct call error checks. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
fdf62e8562
commit
fed5e76e7f
1 changed files with 23 additions and 0 deletions
|
@ -15,12 +15,14 @@ import (
|
||||||
rpcclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
rpcclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/signature"
|
"github.com/nspcc-dev/neofs-api-go/v2/signature"
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/v2/status"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/client"
|
"github.com/nspcc-dev/neofs-node/pkg/core/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||||
objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object"
|
objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object"
|
||||||
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
|
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/internal"
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/internal"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
||||||
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||||
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
|
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||||
|
@ -133,6 +135,10 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre
|
||||||
return nil, fmt.Errorf("response verification failed: %w", err)
|
return nil, fmt.Errorf("response verification failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = checkStatus(resp.GetMetaHeader().GetStatus()); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
switch v := resp.GetBody().GetObjectPart().(type) {
|
switch v := resp.GetBody().GetObjectPart().(type) {
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unexpected object part %T", v)
|
return nil, fmt.Errorf("unexpected object part %T", v)
|
||||||
|
@ -269,6 +275,10 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get
|
||||||
return nil, fmt.Errorf("could not verify %T: %w", resp, err)
|
return nil, fmt.Errorf("could not verify %T: %w", resp, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = checkStatus(resp.GetMetaHeader().GetStatus()); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
switch v := resp.GetBody().GetRangePart().(type) {
|
switch v := resp.GetBody().GetRangePart().(type) {
|
||||||
case nil:
|
case nil:
|
||||||
return nil, fmt.Errorf("unexpected range type %T", v)
|
return nil, fmt.Errorf("unexpected range type %T", v)
|
||||||
|
@ -442,6 +452,10 @@ func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp
|
||||||
return nil, fmt.Errorf("response verification failed: %w", err)
|
return nil, fmt.Errorf("response verification failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = checkStatus(resp.GetMetaHeader().GetStatus()); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
hdr *objectV2.Header
|
hdr *objectV2.Header
|
||||||
idSig *refs.Signature
|
idSig *refs.Signature
|
||||||
|
@ -621,3 +635,12 @@ func writeCurrentVersion(metaHdr *session.RequestMetaHeader) {
|
||||||
|
|
||||||
metaHdr.SetVersion(versionV2)
|
metaHdr.SetVersion(versionV2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkStatus(stV2 *status.Status) error {
|
||||||
|
if !status.IsSuccess(stV2.Code()) {
|
||||||
|
st := apistatus.FromStatusV2(stV2)
|
||||||
|
return apistatus.ErrFromStatus(st)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue