From 622eb9339e7e821394f9a755d8c9b8c96ce25bf9 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 21 Nov 2014 15:54:30 -0800 Subject: [PATCH] Node: Apply a request timeout when communicating with nodes. Signed-off-by: Andrea Luzzardi --- cluster/node.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cluster/node.go b/cluster/node.go index ba3502ccf2..4f5d950d84 100644 --- a/cluster/node.go +++ b/cluster/node.go @@ -15,6 +15,9 @@ import ( const ( // Force-refresh the state of the node this often. stateRefreshPeriod = 30 * time.Second + + // Timeout for requests sent out to the node. + requestTimeout = 10 * time.Second ) func NewNode(addr string) *Node { @@ -47,7 +50,7 @@ type Node struct { // Connect will initialize a connection to the Docker daemon running on the // host, gather machine specs (memory, cpu, ...) and monitor state changes. func (n *Node) Connect(config *tls.Config) error { - c, err := dockerclient.NewDockerClient(n.Addr, config) + c, err := dockerclient.NewDockerClientTimeout(n.Addr, config, time.Duration(requestTimeout)) if err != nil { return err }