add a 10s timeout to the client object.

This partially mitigates #1739 ("Docker commands take 1 minute to timeout if
context endpoint is unreachable") and is a simpler alternative to #1747 (which
completely defers the client connection until an actual call is attempted).

Note that the previous 60s delay was the culmination of two separate 30s
timeouts since the ping is tried twice. This with this patch the overall
timeout is 20s. https://github.com/moby/moby/pull/39206 will remove the second
ping and once that propagates to this tree the timeout will be 10s.

Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
Ian Campbell 2019-05-13 13:31:00 +01:00
parent 53fc257292
commit 59defcb34d
1 changed files with 1 additions and 0 deletions

View File

@ -122,6 +122,7 @@ func (c *Endpoint) ClientOpts() ([]client.Opt, error) {
client.WithDialContext(helper.Dialer),
)
}
result = append(result, client.WithTimeout(10*time.Second))
}
version := os.Getenv("DOCKER_API_VERSION")