From 1fdbfb0dab0244167acbb4b01c985602e92f3578 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 18 May 2023 16:27:30 +0300 Subject: [PATCH] [#110] tree: Update errors to switch endpoint Signed-off-by: Denis Kirillov --- internal/frostfs/services/tree_client_grpc.go | 30 ++----------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/internal/frostfs/services/tree_client_grpc.go b/internal/frostfs/services/tree_client_grpc.go index a6a3c99a..9e544c9a 100644 --- a/internal/frostfs/services/tree_client_grpc.go +++ b/internal/frostfs/services/tree_client_grpc.go @@ -18,8 +18,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "go.uber.org/zap" "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) type GetNodeByPathResponseInfoWrapper struct { @@ -346,31 +344,9 @@ func (c *ServiceClientGRPC) requestWithRetry(fn func(client treeClient) error) ( } func shouldTryAgain(err error) bool { - if err == nil { - return false - } - - code := status.Code(unwrapErr(err)) - if code == codes.Unavailable || code == codes.Unimplemented { - return true - } - - errText := err.Error() - if strings.Contains(errText, "not found") || - strings.Contains(errText, "shard is in read-only mode") || - strings.Contains(errText, "shard is in degraded mode") { - return true - } - - return false -} - -func unwrapErr(err error) error { - for e := errors.Unwrap(err); e != nil; e = errors.Unwrap(err) { - err = e - } - - return err + return !(err == nil || + errors.Is(err, tree.ErrNodeNotFound) || + errors.Is(err, tree.ErrNodeAccessDenied)) } func metaToKV(meta map[string]string) []*grpcService.KeyValue {