Merge pull request #4092 from hashicorp/health-check-only-if-detected
Only run health check if driver moves from undetected to detected
This commit is contained in:
commit
bad69b5233
|
@ -284,6 +284,7 @@ func (fm *FingerprintManager) watchDriver(d driver.Driver, name string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
driverEverDetected := false
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-fm.shutdownCh:
|
case <-fm.shutdownCh:
|
||||||
|
@ -292,16 +293,20 @@ func (fm *FingerprintManager) watchDriver(d driver.Driver, name string) {
|
||||||
if _, err := fm.fingerprintDriver(name, d); err != nil {
|
if _, err := fm.fingerprintDriver(name, d); err != nil {
|
||||||
fm.logger.Printf("[DEBUG] client.fingerprint_manager: periodic fingerprinting for driver %v failed: %+v", name, err)
|
fm.logger.Printf("[DEBUG] client.fingerprint_manager: periodic fingerprinting for driver %v failed: %+v", name, err)
|
||||||
}
|
}
|
||||||
case <-healthTicker:
|
|
||||||
// Determine if we should run the health check
|
|
||||||
fm.nodeLock.Lock()
|
fm.nodeLock.Lock()
|
||||||
driver, detected := fm.node.Drivers[name]
|
driver, detected := fm.node.Drivers[name]
|
||||||
if detected && driver != nil {
|
|
||||||
detected = driver.Detected
|
// Memoize the driver detected status, so that we know whether to run the
|
||||||
|
// health check or not.
|
||||||
|
if detected && driver != nil && driver.Detected {
|
||||||
|
if !driverEverDetected {
|
||||||
|
driverEverDetected = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fm.nodeLock.Unlock()
|
fm.nodeLock.Unlock()
|
||||||
|
case <-healthTicker:
|
||||||
if detected {
|
if driverEverDetected {
|
||||||
if err := fm.runDriverHealthCheck(name, hc); err != nil {
|
if err := fm.runDriverHealthCheck(name, hc); err != nil {
|
||||||
fm.logger.Printf("[DEBUG] client.fingerprint_manager: health checking for %v failed: %v", name, err)
|
fm.logger.Printf("[DEBUG] client.fingerprint_manager: health checking for %v failed: %v", name, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue