From 2adea66b29f2116d43250cf5c69aedc574807290 Mon Sep 17 00:00:00 2001 From: Chelsea Holland Komlo Date: Wed, 21 Mar 2018 13:05:37 -0400 Subject: [PATCH] set driver to unhealthy once if it cannot be detected in periodic check --- client/fingerprint_manager.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/fingerprint_manager.go b/client/fingerprint_manager.go index d8b94cac022a..ec7f45cb748a 100644 --- a/client/fingerprint_manager.go +++ b/client/fingerprint_manager.go @@ -1,6 +1,7 @@ package client import ( + "fmt" "log" "strings" "sync" @@ -308,6 +309,21 @@ 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. + if driver.Healthy { + healthInfo := &structs.DriverInfo{ + Healthy: detected, + 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() + } + } } } }