From 602c42a2371285a15dd35531b53121b11324317e Mon Sep 17 00:00:00 2001 From: Aleksey Savchuk Date: Tue, 22 Oct 2024 10:18:01 +0300 Subject: [PATCH] [#1441] cli: Use `grpc.WaitForReady` while initializing SDK client Before, when the target RPC server was unavailable, requests made by CLI didn't wait for a timeout specified by the `--timeout` option if the timeout was more than 20 seconds. It's because of the gRPC default backoff strategy. Adding this option fixes that behavior. Signed-off-by: Aleksey Savchuk --- cmd/frostfs-cli/internal/client/sdk.go | 1 + cmd/frostfs-cli/modules/tree/client.go | 1 + 2 files changed, 2 insertions(+) diff --git a/cmd/frostfs-cli/internal/client/sdk.go b/cmd/frostfs-cli/internal/client/sdk.go index f7c48b871..2d9c45cbd 100644 --- a/cmd/frostfs-cli/internal/client/sdk.go +++ b/cmd/frostfs-cli/internal/client/sdk.go @@ -58,6 +58,7 @@ func GetSDKClient(ctx context.Context, cmd *cobra.Command, key *ecdsa.PrivateKey GRPCDialOptions: []grpc.DialOption{ grpc.WithChainUnaryInterceptor(tracing.NewUnaryClientInteceptor()), grpc.WithChainStreamInterceptor(tracing.NewStreamClientInterceptor()), + grpc.WithDefaultCallOptions(grpc.WaitForReady(true)), }, } if timeout := viper.GetDuration(commonflags.Timeout); timeout > 0 { diff --git a/cmd/frostfs-cli/modules/tree/client.go b/cmd/frostfs-cli/modules/tree/client.go index 4e0099f02..6891e711c 100644 --- a/cmd/frostfs-cli/modules/tree/client.go +++ b/cmd/frostfs-cli/modules/tree/client.go @@ -34,6 +34,7 @@ func _client() (tree.TreeServiceClient, error) { metrics.NewStreamClientInterceptor(), tracing.NewStreamClientInterceptor(), ), + grpc.WithDefaultCallOptions(grpc.WaitForReady(true)), } if !strings.HasPrefix(netAddr.URIAddr(), "grpcs:") {