Skip to content

Commit

Permalink
set driver to unhealthy once if it cannot be detected in periodic check
Browse files Browse the repository at this point in the history
  • Loading branch information
chelseakomlo committed Mar 21, 2018
1 parent 179db0d commit 2adea66
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions client/fingerprint_manager.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"fmt"
"log"
"strings"
"sync"
Expand Down Expand Up @@ -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()
}
}
}
}
}
Expand Down

0 comments on commit 2adea66

Please sign in to comment.