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:
Chelsea Komlo 2018-04-09 14:40:33 -04:00 committed by GitHub
commit bad69b5233
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
} }