forked from TrueCloudLab/frostfs-s3-gw
[#110] tree: Update errors to switch endpoint
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
1406f57bba
commit
1fdbfb0dab
1 changed files with 3 additions and 27 deletions
|
@ -18,8 +18,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetNodeByPathResponseInfoWrapper struct {
|
type GetNodeByPathResponseInfoWrapper struct {
|
||||||
|
@ -346,31 +344,9 @@ func (c *ServiceClientGRPC) requestWithRetry(fn func(client treeClient) error) (
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldTryAgain(err error) bool {
|
func shouldTryAgain(err error) bool {
|
||||||
if err == nil {
|
return !(err == nil ||
|
||||||
return false
|
errors.Is(err, tree.ErrNodeNotFound) ||
|
||||||
}
|
errors.Is(err, tree.ErrNodeAccessDenied))
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func metaToKV(meta map[string]string) []*grpcService.KeyValue {
|
func metaToKV(meta map[string]string) []*grpcService.KeyValue {
|
||||||
|
|
Loading…
Reference in a new issue