Skip to content

Commit

Permalink
node/put: be ready to get status response code in forwarded request
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Nov 13, 2024
1 parent 3bed297 commit d0dd35e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/services/object/put/v2/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
sessionV2 "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"
"github.com/nspcc-dev/neofs-node/pkg/services/object/internal"
internalclient "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
)

type streamer struct {
Expand Down Expand Up @@ -178,8 +180,21 @@ func (s *streamer) relayRequest(info client.NodeInfo, c client.MultiAddressClien
err = fmt.Errorf("response verification failed: %w", err)
}

err = checkStatus(resp.GetMetaHeader().GetStatus())
if err != nil {
err = fmt.Errorf("remote node response: %w", err)
}

return
})

return firstErr
}

func checkStatus(stV2 *status.Status) error {
if !status.IsSuccess(stV2.Code()) {
return apistatus.ErrorFromV2(stV2)
}

return nil
}

0 comments on commit d0dd35e

Please sign in to comment.