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
1 changed files with 11 additions and 6 deletions

View File

@ -284,6 +284,7 @@ func (fm *FingerprintManager) watchDriver(d driver.Driver, name string) {
}
}
driverEverDetected := false
for {
select {
case <-fm.shutdownCh:
@ -292,16 +293,20 @@ func (fm *FingerprintManager) watchDriver(d driver.Driver, name string) {
if _, err := fm.fingerprintDriver(name, d); err != nil {
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()
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()
if detected {
case <-healthTicker:
if driverEverDetected {
if err := fm.runDriverHealthCheck(name, hc); err != nil {
fm.logger.Printf("[DEBUG] client.fingerprint_manager: health checking for %v failed: %v", name, err)
}