Merge pull request #5422 from DataDog/grpc-expander-large-replies
gRPC expander: allow realistic server responses, and log errors
This commit is contained in:
commit
e1fe8cba2c
|
|
@ -31,7 +31,10 @@ import (
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
)
|
)
|
||||||
|
|
||||||
const gRPCTimeout = 5 * time.Second
|
const (
|
||||||
|
gRPCTimeout = 5 * time.Second
|
||||||
|
gRPCMaxRecvMsgSize = 128 << 20
|
||||||
|
)
|
||||||
|
|
||||||
type grpcclientstrategy struct {
|
type grpcclientstrategy struct {
|
||||||
grpcClient protos.ExpanderClient
|
grpcClient protos.ExpanderClient
|
||||||
|
|
@ -47,8 +50,6 @@ func NewFilter(expanderCert string, expanderUrl string) expander.Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createGRPCClient(expanderCert string, expanderUrl string) protos.ExpanderClient {
|
func createGRPCClient(expanderCert string, expanderUrl string) protos.ExpanderClient {
|
||||||
var dialOpt grpc.DialOption
|
|
||||||
|
|
||||||
if expanderCert == "" {
|
if expanderCert == "" {
|
||||||
log.Fatalf("GRPC Expander Cert not specified, insecure connections not allowed")
|
log.Fatalf("GRPC Expander Cert not specified, insecure connections not allowed")
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -58,9 +59,12 @@ func createGRPCClient(expanderCert string, expanderUrl string) protos.ExpanderCl
|
||||||
log.Fatalf("Failed to create TLS credentials %v", err)
|
log.Fatalf("Failed to create TLS credentials %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
dialOpt = grpc.WithTransportCredentials(creds)
|
dialOpts := []grpc.DialOption{
|
||||||
klog.V(2).Infof("Dialing: %s with dialopt: %v", expanderUrl, dialOpt)
|
grpc.WithTransportCredentials(creds),
|
||||||
conn, err := grpc.Dial(expanderUrl, dialOpt)
|
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(gRPCMaxRecvMsgSize)),
|
||||||
|
}
|
||||||
|
klog.V(2).Infof("Dialing: %s with dialopt: %v", expanderUrl, dialOpts)
|
||||||
|
conn, err := grpc.Dial(expanderUrl, dialOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Fail to dial server: %v", err)
|
log.Fatalf("Fail to dial server: %v", err)
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -84,7 +88,7 @@ func (g *grpcclientstrategy) BestOptions(expansionOptions []expander.Option, nod
|
||||||
defer cancel()
|
defer cancel()
|
||||||
bestOptionsResponse, err := g.grpcClient.BestOptions(ctx, &protos.BestOptionsRequest{Options: grpcOptionsSlice, NodeMap: grpcNodeMap})
|
bestOptionsResponse, err := g.grpcClient.BestOptions(ctx, &protos.BestOptionsRequest{Options: grpcOptionsSlice, NodeMap: grpcNodeMap})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(4).Info("GRPC call timed out, no options filtered")
|
klog.V(4).Infof("GRPC call failed, no options filtered: %v", err)
|
||||||
return expansionOptions
|
return expansionOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue