Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.09] Provide custom gRPC dialer to override default proxy dialer (#2419) #2457

Merged
merged 1 commit into from Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion connectionbroker/broker.go
Expand Up @@ -4,7 +4,9 @@
package connectionbroker

import (
"net"
"sync"
"time"

"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/remotes"
Expand Down Expand Up @@ -60,9 +62,14 @@ func (b *Broker) SelectRemote(dialOpts ...grpc.DialOption) (*Conn, error) {
return nil, err
}

// gRPC dialer connects to proxy first. Provide a custom dialer here avoid that.
// TODO(anshul) Add an option to configure this.
dialOpts = append(dialOpts,
grpc.WithUnaryInterceptor(grpc_prometheus.UnaryClientInterceptor),
grpc.WithStreamInterceptor(grpc_prometheus.StreamClientInterceptor))
grpc.WithStreamInterceptor(grpc_prometheus.StreamClientInterceptor),
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout("tcp", addr, timeout)
}))

cc, err := grpc.Dial(peer.Addr, dialOpts...)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions manager/state/raft/transport/transport.go
Expand Up @@ -3,6 +3,7 @@
package transport

import (
"net"
"sync"
"time"

Expand Down Expand Up @@ -348,6 +349,13 @@ func (t *Transport) dial(addr string) (*grpc.ClientConn, error) {
grpcOptions = append(grpcOptions, grpc.WithTimeout(t.config.SendTimeout))
}

// gRPC dialer connects to proxy first. Provide a custom dialer here avoid that.
// TODO(anshul) Add an option to configure this.
grpcOptions = append(grpcOptions,
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout("tcp", addr, timeout)
}))

cc, err := grpc.Dial(addr, grpcOptions...)
if err != nil {
return nil, err
Expand Down