Skip to content

Commit

Permalink
Change grpc's max sent/recv size to a very large value. (#3912)
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai authored Feb 6, 2018
1 parent acc37c3 commit 85c7b52
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
12 changes: 12 additions & 0 deletions logical/plugin/grpc_backend.go
Original file line number Diff line number Diff line change
@@ -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),
}
4 changes: 2 additions & 2 deletions logical/plugin/grpc_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions logical/plugin/grpc_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion vault/request_forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
math "math"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 85c7b52

Please sign in to comment.