Merge pull request #5310 from gyuho/timeout_v2

etcdctl/ctlv2: total-timeout for Sync
This commit is contained in:
Gyu-Ho Lee 2016-05-10 15:02:33 -07:00
commit d8215c8892

View File

@ -156,7 +156,13 @@ func getTransport(c *cli.Context) (*http.Transport, error) {
CertFile: certfile,
KeyFile: keyfile,
}
return transport.NewTransport(tls, defaultDialTimeout)
dialTimeout := defaultDialTimeout
totalTimeout := c.GlobalDuration("total-timeout")
if totalTimeout != 0 && totalTimeout < dialTimeout {
dialTimeout = totalTimeout
}
return transport.NewTransport(tls, dialTimeout)
}
func getUsernamePasswordFromFlag(usernameFlag string) (username string, password string, err error) {
@ -203,7 +209,7 @@ func mustNewClient(c *cli.Context) client.Client {
if debug {
fmt.Fprintf(os.Stderr, "start to sync cluster using endpoints(%s)\n", strings.Join(hc.Endpoints(), ","))
}
ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
ctx, cancel := contextWithTotalTimeout(c)
err := hc.Sync(ctx)
cancel()
if err != nil {