From 3caa982283dcab2a277bc05a9dddcbe3432fb043 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 27 May 2022 14:16:12 +0300 Subject: [PATCH] [#1442] services/tree: Fix log message for failed `Apply` Signed-off-by: Evgenii Stratonikov --- pkg/services/tree/replicator.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pkg/services/tree/replicator.go b/pkg/services/tree/replicator.go index 4fdaa53f..15ef0b03 100644 --- a/pkg/services/tree/replicator.go +++ b/pkg/services/tree/replicator.go @@ -4,18 +4,15 @@ import ( "bytes" "context" "crypto/sha256" - "encoding/base64" + "encoding/hex" "fmt" "time" - clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" - "github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id" netmapSDK "github.com/nspcc-dev/neofs-sdk-go/netmap" "go.uber.org/zap" - "google.golang.org/grpc" ) type movePair struct { @@ -62,24 +59,23 @@ func (s *Service) replicate(ctx context.Context, op movePair) error { return fmt.Errorf("can't get container nodes: %w", err) } - var node clientcore.NodeInfo for _, n := range nodes { if bytes.Equal(n.PublicKey(), s.rawPub) { continue } var lastErr error + var lastAddr string n.IterateNetworkEndpoints(func(addr string) bool { - cc, err := grpc.DialContext(ctx, addr) + lastAddr = addr + + c, err := dialTreeService(ctx, addr) if err != nil { lastErr = err return false } - // TODO cache clients - c := NewTreeServiceClient(cc) - _, lastErr = c.Apply(ctx, req) return lastErr == nil }) @@ -87,8 +83,8 @@ func (s *Service) replicate(ctx context.Context, op movePair) error { if lastErr != nil { s.log.Warn("failed to sent update to the node", zap.String("last_error", lastErr.Error()), - zap.String("address", network.StringifyGroup(node.AddressGroup())), - zap.String("key", base64.StdEncoding.EncodeToString(node.PublicKey()))) + zap.String("address", lastAddr), + zap.String("key", hex.EncodeToString(n.PublicKey()))) } } return nil