mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #5310 from gyuho/timeout_v2
etcdctl/ctlv2: total-timeout for Sync
This commit is contained in:
commit
d8215c8892
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user