Skip to content

Commit

Permalink
Fix: grpc: received message larger than max
Browse files Browse the repository at this point in the history
Signed-off-by: Xinfeng Liu <[email protected]>
  • Loading branch information
xinfengliu committed Sep 23, 2020
1 parent 03ed627 commit 03b1989
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 9 deletions.
4 changes: 3 additions & 1 deletion cmd/swarmctl/cluster/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/cmd/swarmctl/common"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)

var (
Expand All @@ -31,7 +32,8 @@ var (
if err != nil {
return err
}
r, err := c.ListClusters(common.Context(cmd), &api.ListClustersRequest{})
r, err := c.ListClusters(common.Context(cmd), &api.ListClustersRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/swarmctl/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
import (
"context"
"crypto/tls"
"math"
"net"
"strings"
"time"
Expand All @@ -15,6 +16,8 @@ import (
"google.golang.org/grpc/credentials"
)

const DefaultRecvSizeForListResponse = math.MaxInt32

// Dial establishes a connection and creates a client.
// It infers connection parameters from CLI options.
func Dial(cmd *cobra.Command) (api.ControlClient, error) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/swarmctl/config/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/dustin/go-humanize"
gogotypes "github.com/gogo/protobuf/types"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)

type configSorter []*api.Config
Expand Down Expand Up @@ -50,7 +51,8 @@ var (
return err
}

resp, err := client.ListConfigs(common.Context(cmd), &api.ListConfigsRequest{})
resp, err := client.ListConfigs(common.Context(cmd), &api.ListConfigsRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/swarmctl/network/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/cmd/swarmctl/common"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)

var (
Expand All @@ -31,7 +32,8 @@ var (
if err != nil {
return err
}
r, err := c.ListNetworks(common.Context(cmd), &api.ListNetworksRequest{})
r, err := c.ListNetworks(common.Context(cmd), &api.ListNetworksRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/swarmctl/node/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/cmd/swarmctl/common"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)

var (
Expand All @@ -31,7 +32,8 @@ var (
if err != nil {
return err
}
r, err := c.ListNodes(common.Context(cmd), &api.ListNodesRequest{})
r, err := c.ListNodes(common.Context(cmd), &api.ListNodesRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/swarmctl/secret/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/dustin/go-humanize"
gogotypes "github.com/gogo/protobuf/types"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)

type secretSorter []*api.Secret
Expand Down Expand Up @@ -50,7 +51,8 @@ var (
return err
}

resp, err := client.ListSecrets(common.Context(cmd), &api.ListSecretsRequest{})
resp, err := client.ListSecrets(common.Context(cmd), &api.ListSecretsRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}
Expand Down
10 changes: 7 additions & 3 deletions cmd/swarmctl/service/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/cmd/swarmctl/common"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)

var (
Expand All @@ -31,12 +32,14 @@ var (
if err != nil {
return err
}
r, err := c.ListServices(common.Context(cmd), &api.ListServicesRequest{})
r, err := c.ListServices(common.Context(cmd), &api.ListServicesRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}

nr, err := c.ListNodes(common.Context(cmd), &api.ListNodesRequest{})
nr, err := c.ListNodes(common.Context(cmd), &api.ListNodesRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}
Expand All @@ -50,7 +53,8 @@ var (
var output func(j *api.Service)

if !quiet {
tr, err := c.ListTasks(common.Context(cmd), &api.ListTasksRequest{})
tr, err := c.ListTasks(common.Context(cmd), &api.ListTasksRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/swarmctl/task/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/cmd/swarmctl/common"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)

var (
Expand Down Expand Up @@ -36,7 +37,8 @@ var (
if err != nil {
return err
}
r, err := c.ListTasks(common.Context(cmd), &api.ListTasksRequest{})
r, err := c.ListTasks(common.Context(cmd), &api.ListTasksRequest{},
grpc.MaxCallRecvMsgSize(common.DefaultRecvSizeForListResponse))
if err != nil {
return err
}
Expand Down

0 comments on commit 03b1989

Please sign in to comment.