From b1a943fa3dff6a9a0d7f802111334be7d1175492 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 22 Oct 2024 18:19:21 -0500 Subject: compiles and runs Signed-off-by: Jeff Carr --- poll.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'poll.go') diff --git a/poll.go b/poll.go index 41f0349..12c07af 100644 --- a/poll.go +++ b/poll.go @@ -36,7 +36,7 @@ func (h *HyperT) pollHypervisor() { // this is a new unknown droplet (not in the config file) d = new(DropletT) d.pb.Hostname = name - d.hname = h.pb.Hostname + d.h = h d.lastpoll = time.Now() d.CurrentState = "ON" me.droplets = append(me.droplets, d) @@ -49,24 +49,24 @@ func (h *HyperT) pollHypervisor() { d.lastpoll = time.Now() // this means the droplet is still where it was before - if d.hname == h.pb.Hostname { + if d.h.pb.Hostname == h.pb.Hostname { continue } - if d.hname == "" { + if d.h == nil { // this means the droplet was in the config file // but this is the first time it's shown up as running // this should mean a droplet is running where the config file says it probably should be running - if d.hyperPreferred == h.pb.Hostname { + if d.pb.PreferredHypervisor == h.pb.Hostname { log.Log(EVENT, "new droplet", d.pb.Hostname, "(matches config hypervisor", h.pb.Hostname+")") - d.hname = h.pb.Hostname + d.h = h continue } log.Log(EVENT, "new droplet", d.pb.Hostname, "on", h.pb.Hostname, "(in config file without preferred hypervisor)") } - d.hname = h.pb.Hostname + d.h = h } continue } @@ -115,14 +115,18 @@ func clusterHealthy() (bool, string) { unknownList = append(unknownList, d.pb.Hostname) continue } + var hname string + if d.h != nil { + hname = d.h.pb.Hostname + } if d.CurrentState != "ON" { - log.Info("BAD STATE", d.pb.StartState, d.pb.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur)) + log.Info("BAD STATE", d.pb.StartState, d.pb.Hostname, hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur)) good = false failed += 1 } else { dur := time.Since(d.lastpoll) // Calculate the elapsed time if dur > time.Minute { - log.Info("GOOD STATE MISSING", d.pb.Hostname, d.hname, shell.FormatDuration(dur)) + log.Info("GOOD STATE MISSING", d.pb.Hostname, hname, shell.FormatDuration(dur)) good = false d.CurrentState = "MISSING" failed += 1 -- cgit v1.2.3