Merge pull request #586 from stevvooe/dist-grpc-connect
cmd/dist: add global connect-timeout for GRPC
This commit is contained in:
commit
4793f968e5
3 changed files with 9 additions and 4 deletions
2
cmd/dist/common.go
vendored
2
cmd/dist/common.go
vendored
|
@ -24,7 +24,9 @@ func resolveContentStore(context *cli.Context) (*content.Store, error) {
|
||||||
|
|
||||||
func connectGRPC(context *cli.Context) (*grpc.ClientConn, error) {
|
func connectGRPC(context *cli.Context) (*grpc.ClientConn, error) {
|
||||||
socket := context.GlobalString("socket")
|
socket := context.GlobalString("socket")
|
||||||
|
timeout := context.GlobalDuration("connect-timeout")
|
||||||
return grpc.Dial(socket,
|
return grpc.Dial(socket,
|
||||||
|
grpc.WithTimeout(timeout),
|
||||||
grpc.WithBlock(),
|
grpc.WithBlock(),
|
||||||
grpc.WithInsecure(),
|
grpc.WithInsecure(),
|
||||||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
||||||
|
|
2
cmd/dist/fetch.go
vendored
2
cmd/dist/fetch.go
vendored
|
@ -39,7 +39,7 @@ var fetchCommand = cli.Command{
|
||||||
},
|
},
|
||||||
Action: func(context *cli.Context) error {
|
Action: func(context *cli.Context) error {
|
||||||
var (
|
var (
|
||||||
ctx = contextpkg.Background()
|
ctx = background
|
||||||
timeout = context.Duration("timeout")
|
timeout = context.Duration("timeout")
|
||||||
locator = context.Args().First()
|
locator = context.Args().First()
|
||||||
args = context.Args().Tail()
|
args = context.Args().Tail()
|
||||||
|
|
9
cmd/dist/main.go
vendored
9
cmd/dist/main.go
vendored
|
@ -40,9 +40,12 @@ distribution tool
|
||||||
Usage: "enable debug output in logs",
|
Usage: "enable debug output in logs",
|
||||||
},
|
},
|
||||||
cli.DurationFlag{
|
cli.DurationFlag{
|
||||||
Name: "timeout",
|
Name: "timeout",
|
||||||
Usage: "total timeout for fetch",
|
Usage: "total timeout for dist commands",
|
||||||
EnvVar: "CONTAINERD_FETCH_TIMEOUT",
|
},
|
||||||
|
cli.DurationFlag{
|
||||||
|
Name: "connect-timeout",
|
||||||
|
Usage: "timeout for connecting to containerd",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
// TODO(stevvooe): for now, we allow circumventing the GRPC. Once
|
// TODO(stevvooe): for now, we allow circumventing the GRPC. Once
|
||||||
|
|
Loading…
Reference in a new issue