Improve logging for up/down changes

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2024-04-15 23:11:45 +02:00
parent d51b6dc8e8
commit feb2aa23ab
Signed by: luzifer
SSH key fingerprint: SHA256:/xtE5lCgiRDQr8SLxHMS92ZBlACmATUmF1crK16Ks4E

View file

@ -76,14 +76,24 @@ func (m Monitor) updateRoutingTargets(checker healthcheck.Checker) (err error) {
}
if err := checker.Check(m.svc.HealthCheck.Settings, t); err != nil {
if m.ipt.UnregisterServiceTarget(m.svc.Name, tgt) {
logger.WithError(err).Warn("detected target down")
changed = true
} else {
logger.WithError(err).Debug("detected target down")
changed = changed || m.ipt.UnregisterServiceTarget(m.svc.Name, tgt)
}
down = append(down, t.String())
return
}
if m.ipt.RegisterServiceTarget(m.svc.Name, tgt) {
logger.Info("target up")
changed = true
} else {
logger.Debug("target up")
changed = changed || m.ipt.RegisterServiceTarget(m.svc.Name, tgt)
}
up = append(up, t.String())
}()
}