summaryrefslogtreecommitdiff
path: root/poll.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-22 17:45:50 -0600
committerJeff Carr <[email protected]>2025-02-22 17:45:50 -0600
commit32e27530075a09f5c3b82ca6cbb83a01e34cb24c (patch)
treebf1ad3f04ef77b2425385a4261e36d95909b6988 /poll.go
parent9f9a52312e6e9538e7ec4c0eefbe46aace352fd3 (diff)
switch virtbuf to virtpbv0.2.36
Diffstat (limited to 'poll.go')
-rw-r--r--poll.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/poll.go b/poll.go
index 15f8aa4..55870e8 100644
--- a/poll.go
+++ b/poll.go
@@ -6,7 +6,7 @@ import (
"time"
"go.wit.com/lib/gui/shell"
- pb "go.wit.com/lib/protobuf/virtbuf"
+ "go.wit.com/lib/protobuf/virtpb"
"go.wit.com/log"
"google.golang.org/protobuf/types/known/timestamppb"
)
@@ -69,7 +69,7 @@ func (h *HyperT) pollHypervisor() {
log.Log(POLL, start, "STATE:", state, "rest:", fields[2:])
// update the status to ON
- d.SetState(pb.DropletState_ON)
+ d.SetState(virtpb.DropletState_ON)
// set the LastPoll time to now
now := time.Now()
@@ -121,28 +121,28 @@ func (h *HyperT) pollHypervisor() {
// should delete this from h.lastDroplets
continue
}
- if d.Current.State == pb.DropletState_OFF {
+ if d.Current.State == virtpb.DropletState_OFF {
log.Info(header, "droplet timed out and is off. remove from h.lastDroplets[] slice")
delete(h.lastDroplets, name)
continue
}
// everthing below here is dumb and needs to be rethought
- if d.Current.State != pb.DropletState_UNKNOWN {
- d.SetState(pb.DropletState_UNKNOWN)
+ if d.Current.State != virtpb.DropletState_UNKNOWN {
+ d.SetState(virtpb.DropletState_UNKNOWN)
log.Info(header, "set state UNKNOWN here", name)
}
- if d.Current.State == pb.DropletState_UNKNOWN {
+ if d.Current.State == virtpb.DropletState_UNKNOWN {
if dur > time.Minute*2 {
// what this means is the droplet probably wasn't migrated or the migrate failed
// where should this be checked? the status needs to be changed to OFF
- s := pb.FormatDuration(dur)
+ s := virtpb.FormatDuration(dur)
log.Info(header, "UNKNOWN state for more than 2 minutes (clearing out ?)", name, s)
// it might be safe to set the status to OFF here. not really. this poll needs
// to be moved somewhere else. there needs to be a new goroutine not tied to the
// hypervisor
- d.SetState(pb.DropletState_OFF)
+ d.SetState(virtpb.DropletState_OFF)
}
}
}
@@ -158,7 +158,7 @@ func uptimeCheck() (bool, string) {
var total int
var working int
var failed int
- var missing []*pb.Droplet
+ var missing []*virtpb.Droplet
var unknown int
var unknownList []string
@@ -166,7 +166,7 @@ func uptimeCheck() (bool, string) {
for loop.Scan() {
d := loop.Next()
total += 1
- if d.StartState != pb.DropletState_ON {
+ if d.StartState != virtpb.DropletState_ON {
continue
}
dur := time.Since(d.Current.LastPoll.AsTime()) // Calculate the elapsed time
@@ -175,19 +175,19 @@ func uptimeCheck() (bool, string) {
hname = d.Current.Hypervisor
}
switch d.Current.State {
- case pb.DropletState_UNKNOWN:
+ case virtpb.DropletState_UNKNOWN:
// log.Info("SKIP. hostname has not been polled yet", d.Hostname, d.hname)
unknown += 1
unknownList = append(unknownList, d.Hostname)
- case pb.DropletState_ON:
+ case virtpb.DropletState_ON:
if dur > me.missingDropletTimeout {
- log.Info("GOOD STATE MISSING", d.Hostname, hname, pb.FormatDuration(dur))
+ log.Info("GOOD STATE MISSING", d.Hostname, hname, virtpb.FormatDuration(dur))
good = false
- d.SetState(pb.DropletState_UNKNOWN)
+ d.SetState(virtpb.DropletState_UNKNOWN)
failed += 1
continue
}
- l := pb.FormatDuration(dur)
+ l := virtpb.FormatDuration(dur)
if l == "" {
log.Info("DUR IS EMPTY", dur)
missing = append(missing, d)
@@ -195,13 +195,13 @@ func uptimeCheck() (bool, string) {
}
working += 1
// log.Info("GOOD STATE ON", d.Hostname, d.hname, "dur =", l)
- case pb.DropletState_OFF:
- log.Info("OFF STATE", d.StartState, d.Hostname, hname, pb.FormatDuration(dur))
+ case virtpb.DropletState_OFF:
+ log.Info("OFF STATE", d.StartState, d.Hostname, hname, virtpb.FormatDuration(dur))
good = false
failed += 1
// missing = append(missing, d)
default:
- log.Info("WTF STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, pb.FormatDuration(dur))
+ log.Info("WTF STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, virtpb.FormatDuration(dur))
good = false
failed += 1
missing = append(missing, d)
@@ -225,7 +225,7 @@ func uptimeCheck() (bool, string) {
summary += "(killcount=" + fmt.Sprintf("%d", me.killcount) + ")"
}
last := time.Since(me.unstable)
- s := strings.TrimSpace(pb.FormatDuration(last))
+ s := strings.TrimSpace(virtpb.FormatDuration(last))
if last > me.clusterStableDuration {
// the cluster has not been stable for 10 seconds
summary += "(stable=" + s + ")"