etcdctl: use user specified timeout value for entire command execution

etcdctl should be capable to use a user specified timeout value for
total command execution, not only per request timeout. This commit
adds a new option --total-timeout to the command. The value passed via
this option is used as a timeout value of entire command execution.

Fixes coreos#3517
This commit is contained in:
Hitoshi Mitake
2015-09-24 13:52:07 +09:00
parent c645ac23c0
commit 8ebc933111
6 changed files with 34 additions and 44 deletions

View File

@ -20,7 +20,6 @@ import (
"strings"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
"github.com/coreos/etcd/client"
)
@ -67,7 +66,7 @@ func authEnableDisable(c *cli.Context, enable bool) {
os.Exit(1)
}
s := mustNewAuthAPI(c)
ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
ctx, cancel := contextWithTotalTimeout(c)
var err error
if enable {
err = s.Enable(ctx)