Merge pull request #586 from stevvooe/dist-grpc-connect

cmd/dist: add global connect-timeout for GRPC
This commit is contained in:
Stephen Day 2017-02-28 17:12:00 -08:00 committed by GitHub
commit 4793f968e5
3 changed files with 9 additions and 4 deletions

2
cmd/dist/common.go vendored
View File

@ -24,7 +24,9 @@ func resolveContentStore(context *cli.Context) (*content.Store, error) {
func connectGRPC(context *cli.Context) (*grpc.ClientConn, error) {
socket := context.GlobalString("socket")
timeout := context.GlobalDuration("connect-timeout")
return grpc.Dial(socket,
grpc.WithTimeout(timeout),
grpc.WithBlock(),
grpc.WithInsecure(),
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {

2
cmd/dist/fetch.go vendored
View File

@ -39,7 +39,7 @@ var fetchCommand = cli.Command{
},
Action: func(context *cli.Context) error {
var (
ctx = contextpkg.Background()
ctx = background
timeout = context.Duration("timeout")
locator = context.Args().First()
args = context.Args().Tail()

9
cmd/dist/main.go vendored
View File

@ -40,9 +40,12 @@ distribution tool
Usage: "enable debug output in logs",
},
cli.DurationFlag{
Name: "timeout",
Usage: "total timeout for fetch",
EnvVar: "CONTAINERD_FETCH_TIMEOUT",
Name: "timeout",
Usage: "total timeout for dist commands",
},
cli.DurationFlag{
Name: "connect-timeout",
Usage: "timeout for connecting to containerd",
},
cli.StringFlag{
// TODO(stevvooe): for now, we allow circumventing the GRPC. Once