mirror of https://github.com/docker/docs.git
remove sleep in integration after etcd store startup, periodic SyncCluster in etcd and include fix to SyncCluster in go-etcd lib
Signed-off-by: Alexandre Beslic <abronan@docker.com>
This commit is contained in:
parent
6eb5cd3b5c
commit
c0fe0bc17d
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue