set driver to unhealthy once if it cannot be detected in periodic check

This commit is contained in:
Chelsea Holland Komlo 2018-03-21 13:05:37 -04:00
parent 5df4b3728d
commit bbaffe3eca
1 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package client
import (
"fmt"
"log"
"strings"
"sync"
@ -308,6 +309,19 @@ func (fm *FingerprintManager) watchDriver(d driver.Driver, name string) {
if err := fm.runDriverHealthCheck(name, hc); err != nil {
fm.logger.Printf("[DEBUG] client.fingerprint_manager: health checking for %v failed: %v", name, err)
}
} else {
// If the driver is undetected, change the health status to unhealthy
// only once.
healthInfo := &structs.DriverInfo{
Healthy: false,
HealthDescription: fmt.Sprintf("Driver %s is not detected", name),
UpdateTime: time.Now(),
}
if node := fm.updateNodeFromDriver(name, nil, healthInfo); node != nil {
fm.nodeLock.Lock()
fm.node = node
fm.nodeLock.Unlock()
}
}
}
}