client: log detected driver health state

Noticed that `detected drivers` log line was misleading - when a driver
doesn't fingerprint before timeout, their health status is empty string
`""` which we would mark as detected.

Now, we log all drivers along with their state to ease driver
fingerprint debugging.
This commit is contained in:
Mahmood Ali 2019-04-19 09:15:25 -04:00
parent 6bdc9860b7
commit f74d60439f

View file

@ -243,9 +243,18 @@ func (m *manager) waitForFirstFingerprint(ctx context.Context, cancel context.Ca
}
var mu sync.Mutex
var availDrivers []string
driversByStatus := map[drivers.HealthState][]string{}
var wg sync.WaitGroup
recordDriver := func(name string, lastHeath drivers.HealthState) {
mu.Lock()
defer mu.Unlock()
updated := append(driversByStatus[lastHeath], name)
driversByStatus[lastHeath] = updated
}
// loop through instances and wait for each to finish initial fingerprint
m.instancesMu.RLock()
for n, i := range m.instances {
@ -253,16 +262,13 @@ func (m *manager) waitForFirstFingerprint(ctx context.Context, cancel context.Ca
go func(name string, instance *instanceManager) {
defer wg.Done()
instance.WaitForFirstFingerprint(ctx)
if instance.getLastHealth() != drivers.HealthStateUndetected {
mu.Lock()
availDrivers = append(availDrivers, name)
mu.Unlock()
}
recordDriver(name, instance.getLastHealth())
}(n, i)
}
m.instancesMu.RUnlock()
wg.Wait()
m.logger.Debug("detected drivers", "drivers", availDrivers)
m.logger.Debug("detected drivers", "drivers", driversByStatus)
}
func (m *manager) loadReattachConfigs() error {