From b799d2df7854f8b5b53b92e10e49e2b39663bda0 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 13 Nov 2024 17:19:12 +0300 Subject: [PATCH] node/search: be ready to get status code from forwarded request It does not change the seen behavior, but now error logs will be printed. Signed-off-by: Pavel Karpy --- CHANGELOG.md | 2 +- pkg/services/object/search/v2/util.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7ed5d0aa1..2a04c7cc77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ attribute, which is used for container domain name in NNS contracts (#2954) - RPC client reconnection failures leading to complete SN failure (#2797) - `meta.DB.Open(readOnly)` moves metabase in RO mode (#3000) - Panic in event listener related to inability to switch RPC node (#2970) -- Non-container nodes never check placement policy on PUT requests (#3014) +- Non-container nodes never check placement policy on PUT, SEARCH requests (#3014) ### Changed - `ObjectService`'s `Put` RPC handler caches up to 10K lists of per-object sorted container nodes (#2901) diff --git a/pkg/services/object/search/v2/util.go b/pkg/services/object/search/v2/util.go index 10903fe05b..4b863598c4 100644 --- a/pkg/services/object/search/v2/util.go +++ b/pkg/services/object/search/v2/util.go @@ -11,12 +11,14 @@ import ( 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/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/network" objectSvc "github.com/nspcc-dev/neofs-node/pkg/services/object" "github.com/nspcc-dev/neofs-node/pkg/services/object/internal" searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search" "github.com/nspcc-dev/neofs-node/pkg/services/object/util" + 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/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" @@ -116,6 +118,10 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre return nil, fmt.Errorf("could not verify %T: %w", resp, err) } + if err := checkStatus(resp.GetMetaHeader().GetStatus()); err != nil { + return nil, fmt.Errorf("remote node response: %w", err) + } + chunk := resp.GetBody().GetIDList() var id oid.ID @@ -139,6 +145,14 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre return p, nil } +func checkStatus(stV2 *status.Status) error { + if !status.IsSuccess(stV2.Code()) { + return apistatus.ErrorFromV2(stV2) + } + + return nil +} + func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) ([]oid.ID, error)) searchsvc.RequestForwarder { return func(info client.NodeInfo, c client.MultiAddressClient) ([]oid.ID, error) { var (