Some output tweaks; and some additional transition events upon resume (paused->unknown->{up|down})
This commit is contained in:
@@ -35,6 +35,7 @@ type worker struct {
|
||||
hc config.HealthCheck
|
||||
entry config.Backend
|
||||
cancel context.CancelFunc
|
||||
wakeCh chan struct{} // closed/signalled to interrupt probe sleep on resume
|
||||
}
|
||||
|
||||
// Checker orchestrates health probing for all backends.
|
||||
@@ -236,8 +237,12 @@ func (c *Checker) PauseBackend(name string) (BackendSnapshot, bool) {
|
||||
}
|
||||
maxHistory := c.cfg.HealthChecker.TransitionHistory
|
||||
if w.backend.Pause(maxHistory) {
|
||||
slog.Info("backend-pause", "backend", name)
|
||||
c.emitForBackend(name, w.backend.Address, w.backend.Transitions[0], c.cfg.Frontends)
|
||||
t := w.backend.Transitions[0]
|
||||
slog.Info("backend-transition", "backend", name,
|
||||
"from", t.From.String(),
|
||||
"to", t.To.String(),
|
||||
)
|
||||
c.emitForBackend(name, w.backend.Address, t, c.cfg.Frontends)
|
||||
}
|
||||
return BackendSnapshot{Health: w.backend, Config: w.entry}, true
|
||||
}
|
||||
@@ -252,8 +257,16 @@ func (c *Checker) ResumeBackend(name string) (BackendSnapshot, bool) {
|
||||
}
|
||||
maxHistory := c.cfg.HealthChecker.TransitionHistory
|
||||
if w.backend.Resume(maxHistory) {
|
||||
slog.Info("backend-resume", "backend", name)
|
||||
c.emitForBackend(name, w.backend.Address, w.backend.Transitions[0], c.cfg.Frontends)
|
||||
t := w.backend.Transitions[0]
|
||||
slog.Info("backend-transition", "backend", name,
|
||||
"from", t.From.String(),
|
||||
"to", t.To.String(),
|
||||
)
|
||||
c.emitForBackend(name, w.backend.Address, t, c.cfg.Frontends)
|
||||
select {
|
||||
case w.wakeCh <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
return BackendSnapshot{Health: w.backend, Config: w.entry}, true
|
||||
}
|
||||
@@ -274,6 +287,7 @@ func (c *Checker) startWorker(ctx context.Context, name string, entry config.Bac
|
||||
hc: hc,
|
||||
entry: entry,
|
||||
cancel: cancel,
|
||||
wakeCh: make(chan struct{}, 1),
|
||||
}
|
||||
w.backend.Start(maxHistory)
|
||||
c.workers[name] = w
|
||||
@@ -310,6 +324,7 @@ func (c *Checker) runProbe(ctx context.Context, name string, pos, total int) {
|
||||
entry := w.entry
|
||||
maxHistory := c.cfg.HealthChecker.TransitionHistory
|
||||
netns := c.cfg.HealthChecker.Netns
|
||||
wakeCh := w.wakeCh
|
||||
var sleepFor time.Duration
|
||||
if entry.HealthCheck == "" {
|
||||
sleepFor = 30 * time.Second
|
||||
@@ -322,6 +337,7 @@ func (c *Checker) runProbe(ctx context.Context, name string, pos, total int) {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(sleepFor):
|
||||
case <-wakeCh:
|
||||
}
|
||||
|
||||
var result health.ProbeResult
|
||||
|
||||
Reference in New Issue
Block a user