From 85c7b528e22c300efdc5ae39beccfe54802d9780 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 6 Feb 2018 13:52:35 -0500 Subject: [PATCH] Change grpc's max sent/recv size to a very large value. (#3912) --- logical/plugin/grpc_backend.go | 12 ++++++++++++ logical/plugin/grpc_backend_client.go | 4 ++-- logical/plugin/grpc_storage.go | 6 +++--- vault/request_forwarding.go | 7 ++++++- 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 logical/plugin/grpc_backend.go diff --git a/logical/plugin/grpc_backend.go b/logical/plugin/grpc_backend.go new file mode 100644 index 000000000000..a65eeebeb432 --- /dev/null +++ b/logical/plugin/grpc_backend.go @@ -0,0 +1,12 @@ +package plugin + +import ( + "math" + + "google.golang.org/grpc" +) + +var largeMsgGRPCCallOpts []grpc.CallOption = []grpc.CallOption{ + grpc.MaxCallSendMsgSize(math.MaxInt32), + grpc.MaxCallRecvMsgSize(math.MaxInt32), +} diff --git a/logical/plugin/grpc_backend_client.go b/logical/plugin/grpc_backend_client.go index ba7bdbdd88c3..8e584d778d3f 100644 --- a/logical/plugin/grpc_backend_client.go +++ b/logical/plugin/grpc_backend_client.go @@ -53,7 +53,7 @@ func (b *backendGRPCPluginClient) HandleRequest(ctx context.Context, req *logica reply, err := b.client.HandleRequest(ctx, &pb.HandleRequestArgs{ Request: protoReq, - }) + }, largeMsgGRPCCallOpts...) if err != nil { if b.doneCtx.Err() != nil { return nil, ErrPluginShutdown @@ -115,7 +115,7 @@ func (b *backendGRPCPluginClient) HandleExistenceCheck(ctx context.Context, req defer cancel() reply, err := b.client.HandleExistenceCheck(ctx, &pb.HandleExistenceCheckArgs{ Request: protoReq, - }) + }, largeMsgGRPCCallOpts...) if err != nil { if b.doneCtx.Err() != nil { return false, false, ErrPluginShutdown diff --git a/logical/plugin/grpc_storage.go b/logical/plugin/grpc_storage.go index b3eb7d28ef67..cfc236877357 100644 --- a/logical/plugin/grpc_storage.go +++ b/logical/plugin/grpc_storage.go @@ -25,7 +25,7 @@ type GRPCStorageClient struct { func (s *GRPCStorageClient) List(ctx context.Context, prefix string) ([]string, error) { reply, err := s.client.List(ctx, &pb.StorageListArgs{ Prefix: prefix, - }) + }, largeMsgGRPCCallOpts...) if err != nil { return reply.Keys, err } @@ -38,7 +38,7 @@ func (s *GRPCStorageClient) List(ctx context.Context, prefix string) ([]string, func (s *GRPCStorageClient) Get(ctx context.Context, key string) (*logical.StorageEntry, error) { reply, err := s.client.Get(ctx, &pb.StorageGetArgs{ Key: key, - }) + }, largeMsgGRPCCallOpts...) if err != nil { return nil, err } @@ -51,7 +51,7 @@ func (s *GRPCStorageClient) Get(ctx context.Context, key string) (*logical.Stora func (s *GRPCStorageClient) Put(ctx context.Context, entry *logical.StorageEntry) error { reply, err := s.client.Put(ctx, &pb.StoragePutArgs{ Entry: pb.LogicalStorageEntryToProtoStorageEntry(entry), - }) + }, largeMsgGRPCCallOpts...) if err != nil { return err } diff --git a/vault/request_forwarding.go b/vault/request_forwarding.go index 7ca4465e4778..687e647763ea 100644 --- a/vault/request_forwarding.go +++ b/vault/request_forwarding.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "crypto/x509" "fmt" + math "math" "net" "net/http" "net/url" @@ -263,7 +264,11 @@ func (c *Core) refreshRequestForwardingConnection(ctx context.Context, clusterAd grpc.WithInsecure(), // it's not, we handle it in the dialer grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 2 * HeartbeatInterval, - })) + }), + grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32), + grpc.MaxCallSendMsgSize(math.MaxInt32), + )) if err != nil { cancelFunc() c.logger.Error("core: err setting up forwarding rpc client", "error", err)