Skip to content

Commit

Permalink
plugins: Allow the server to receive large messages (#4958)
Browse files Browse the repository at this point in the history
  • Loading branch information
briankassouf authored and jefferai committed Jul 20, 2018
1 parent f09c365 commit e3dc93c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions logical/plugin/grpc_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package plugin
import (
"context"
"errors"
"math"
"sync/atomic"

"google.golang.org/grpc"
Expand Down Expand Up @@ -195,6 +196,9 @@ func (b *backendGRPCPluginClient) Setup(ctx context.Context, config *logical.Bac

// Register the server in this closure.
serverFunc := func(opts []grpc.ServerOption) *grpc.Server {
opts = append(opts, grpc.MaxRecvMsgSize(math.MaxInt32))
opts = append(opts, grpc.MaxSendMsgSize(math.MaxInt32))

s := grpc.NewServer(opts...)
pb.RegisterSystemViewServer(s, sysView)
pb.RegisterStorageServer(s, storage)
Expand Down
9 changes: 8 additions & 1 deletion logical/plugin/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package plugin

import (
"crypto/tls"
"math"
"os"

"google.golang.org/grpc"

log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/vault/helper/pluginutil"
Expand Down Expand Up @@ -54,7 +57,11 @@ func Serve(opts *ServeOpts) error {
Logger: logger,

// A non-nil value here enables gRPC serving for this plugin...
GRPCServer: plugin.DefaultGRPCServer,
GRPCServer: func(opts []grpc.ServerOption) *grpc.Server {
opts = append(opts, grpc.MaxRecvMsgSize(math.MaxInt32))
opts = append(opts, grpc.MaxSendMsgSize(math.MaxInt32))
return plugin.DefaultGRPCServer(opts)
},
}

if !pluginutil.GRPCSupport() {
Expand Down

0 comments on commit e3dc93c

Please sign in to comment.