diff options
| author | Jeff Carr <[email protected]> | 2024-10-23 19:15:51 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-23 19:15:51 -0500 |
| commit | d09f4e25c25dced54d688597b5e9a903c456573d (patch) | |
| tree | 92fe88c807cbb41ef3f60047cd57a493d072db88 /poll.go | |
| parent | 3ce3a0d7f640a71873eea29c70234ec9f4257b03 (diff) | |
switched to pb.DropletState enum
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'poll.go')
| -rw-r--r-- | poll.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -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 } |
