From d09f4e25c25dced54d688597b5e9a903c456573d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 23 Oct 2024 19:15:51 -0500 Subject: switched to pb.DropletState enum Signed-off-by: Jeff Carr --- poll.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'poll.go') diff --git a/poll.go b/poll.go index 7cd7ba6..b8134f5 100644 --- a/poll.go +++ b/poll.go @@ -6,6 +6,7 @@ import ( "time" "go.wit.com/lib/gui/shell" + pb "go.wit.com/lib/protobuf/virtbuf" "go.wit.com/log" ) @@ -38,14 +39,14 @@ func (h *HyperT) pollHypervisor() { d.pb.Hostname = name d.h = h d.lastpoll = time.Now() - d.CurrentState = "ON" + d.CurrentState = pb.DropletState_ON me.droplets = append(me.droplets, d) log.Log(EVENT, name, "IS NEW. ADDED ON", h.pb.Hostname) } log.Log(INFO, "ALREADY RECORDED", d.pb.Hostname) // update the status to ON and the last polled value - d.CurrentState = "ON" + d.CurrentState = pb.DropletState_ON d.lastpoll = time.Now() if d.h == nil { @@ -108,11 +109,11 @@ func clusterHealthy() (bool, string) { for _, d := range me.droplets { total += 1 - if d.pb.StartState != "ON" { + if d.pb.StartState != pb.DropletState_ON { continue } dur := time.Since(d.lastpoll) // Calculate the elapsed time - if d.CurrentState == "" { + if d.CurrentState == pb.DropletState_UNKNOWN { // log.Info("SKIP. hostname has not been polled yet", d.pb.Hostname, d.hname) unknown += 1 unknownList = append(unknownList, d.pb.Hostname) @@ -122,7 +123,7 @@ func clusterHealthy() (bool, string) { if d.h != nil { hname = d.h.pb.Hostname } - if d.CurrentState != "ON" { + if d.CurrentState != pb.DropletState_ON { log.Info("BAD STATE", d.pb.StartState, d.pb.Hostname, hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur)) good = false failed += 1 @@ -131,7 +132,7 @@ func clusterHealthy() (bool, string) { if dur > time.Minute { log.Info("GOOD STATE MISSING", d.pb.Hostname, hname, shell.FormatDuration(dur)) good = false - d.CurrentState = "MISSING" + d.CurrentState = pb.DropletState_UNKNOWN failed += 1 continue } -- cgit v1.2.3