diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e74633e5ad..88f9519108 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -32,8 +32,8 @@ }, { "ImportPath": "github.com/coreos/go-etcd/etcd", - "Comment": "v2.0.0-7-g73a8ef7", - "Rev": "73a8ef737e8ea002281a28b4cb92a1de121ad4c6" + "Comment": "v2.0.0-8-g2698e87", + "Rev": "2698e87871614d7f376775409c701dd538f0b50e" }, { "ImportPath": "github.com/docker/docker/pkg/ioutils", diff --git a/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/client.go b/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/client.go index c6cf3341ba..79ac885b4a 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/client.go +++ b/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd/client.go @@ -312,6 +312,9 @@ func (c *Client) SyncCluster() bool { // internalSyncCluster syncs cluster information using the given machine list. func (c *Client) internalSyncCluster(machines []string) bool { + // comma-separated list of machines in the cluster. + members := "" + for _, machine := range machines { httpPath := c.createHttpPath(machine, path.Join(version, "members")) resp, err := c.httpClient.Get(httpPath) @@ -333,8 +336,7 @@ func (c *Client) internalSyncCluster(machines []string) bool { // try another machine in the cluster continue } - // update Machines List - c.cluster.updateFromStr(string(b)) + members = string(b) } else { b, err := ioutil.ReadAll(resp.Body) resp.Body.Close() @@ -355,9 +357,16 @@ func (c *Client) internalSyncCluster(machines []string) bool { } // update Machines List - c.cluster.updateFromStr(strings.Join(urls, ",")) + members = strings.Join(urls, ",") } + // We should never do an empty cluster update. + if members == "" { + continue + } + + // update Machines List + c.cluster.updateFromStr(members) logger.Debug("sync.machines ", c.cluster.Machines) c.saveConfig() return true diff --git a/pkg/store/etcd.go b/pkg/store/etcd.go index 1ad13e60af..99cd54befe 100644 --- a/pkg/store/etcd.go +++ b/pkg/store/etcd.go @@ -28,6 +28,9 @@ type etcdLock struct { const ( defaultLockTTL = 20 * time.Second defaultUpdateTime = 5 * time.Second + + // periodicSync is the time between each call to SyncCluster + periodicSync = 10 * time.Minute ) // InitializeEtcd creates a new Etcd client given @@ -51,7 +54,12 @@ func InitializeEtcd(addrs []string, options *Config) (Store, error) { } } - s.client.SyncCluster() + go func() { + for { + s.client.SyncCluster() + time.Sleep(periodicSync) + } + }() return s, nil } diff --git a/test/integration/discovery/etcd.bats b/test/integration/discovery/etcd.bats index 54a5d9d1d4..5e585b854b 100644 --- a/test/integration/discovery/etcd.bats +++ b/test/integration/discovery/etcd.bats @@ -19,8 +19,6 @@ function start_store() { quay.io/coreos/etcd:v2.0.11 \ --listen-client-urls="http://0.0.0.0:${PORT}" \ --advertise-client-urls="http://${STORE_HOST}" - - sleep 3 } function stop_store() {