Force node spec update.

Signed-off-by: Dong Chen <dongluo.chen@docker.com>
This commit is contained in:
Dong Chen 2016-03-15 19:30:35 -07:00
parent 73179d4dd8
commit 040f63cd47
1 changed files with 12 additions and 1 deletions

View File

@ -692,6 +692,12 @@ func (e *Engine) updateContainer(c dockerclient.Container, containers map[string
// refreshLoop periodically triggers engine refresh.
func (e *Engine) refreshLoop() {
const maxBackoffFactor int = 1000
// engine can hot-plug CPU/Mem or update labels. but there is no events
// from engine to trigger spec update.
// add an update interval and refresh spec for healthy nodes.
const specUpdateInterval = 5 * time.Minute
lastSpecUpdatedAt := time.Now()
for {
var err error
@ -710,11 +716,16 @@ func (e *Engine) refreshLoop() {
return
}
if !e.IsHealthy() {
healthy := e.IsHealthy()
if !healthy || time.Since(lastSpecUpdatedAt) > specUpdateInterval {
if err = e.updateSpecs(); err != nil {
log.WithFields(log.Fields{"name": e.Name, "id": e.ID}).Errorf("Update engine specs failed: %v", err)
continue
}
lastSpecUpdatedAt = time.Now()
}
if !healthy {
e.client.StopAllMonitorEvents()
e.StartMonitorEvents()
}