Skip to content

Commit

Permalink
cli: Fix false-negative result of Inner Ring healthcheck
Browse files Browse the repository at this point in the history
Previously, IR healthcheck command failed with unimplemented
`neo.fs.v2.netmap.NetmapService`. This was caused by API client
implementation in NeoFS SDK RC-10 which called `EndpointInfo` RPC on
dial: IR nodes doesn't serve NeoFS API, only IR Control API.

As a temp solution, `GetSDKClient` function ignores `Unimplemented` gRPC
errors during client dial.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Aug 8, 2023
1 parent b11429e commit ec52050
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/neofs-cli/internal/client/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/nspcc-dev/neofs-sdk-go/client"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

var errInvalidEndpoint = errors.New("provided RPC endpoint is incorrect")
Expand Down Expand Up @@ -62,6 +64,23 @@ func GetSDKClient(ctx context.Context, cmd *cobra.Command, addr network.Address)
}

if err := c.Dial(prmDial); err != nil { //nolint:contextcheck // SetContext is used above.
// Here is a hack helping IR healthcheck to work. Current API client revision
// calls NetmapService.EndpointInfo RPC which is a part of the NeoFS API
// protocol. Inner ring nodes don't serve NeoFS API services, so they respond
// with Unimplemented code. We ignore this error here:
// - if nodes responds, then dial was successful
// - even if we connect to storage node which MUST provide NeoFS API services,
// subsequent EndpointInfo method will return Unimplemented error anyway
// This behavior is going to be fixed on SDK side.
//
// Track https://github.com/nspcc-dev/neofs-node/issues/2477
wErr := err
for e := errors.Unwrap(wErr); e != nil; e = errors.Unwrap(wErr) {
wErr = e
}
if status.Code(wErr) == codes.Unimplemented {
return c, nil
}
return nil, fmt.Errorf("can't init SDK client: %w", err)
}

Expand Down

0 comments on commit ec52050

Please sign in to comment.