continuing work on tracking droplet state

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-28 08:06:14 -05:00
parent de5f5c6a85
commit c12d3a2dbb
2 changed files with 21 additions and 10 deletions

View File

@ -38,7 +38,7 @@ func dumpDroplets(w http.ResponseWriter) {
}
arp := strings.Join(macs, " ")
if d.CurrentState == pb.DropletState_ON {
fmt.Fprintln(w, i, "droplet:", arp, d.Hostname, d.StartState, d.CurrentState)
fmt.Fprintln(w, i, "droplet:", arp, d.Hostname, d.StartState, d.CurrentState, d.CurrentHypervisor)
continue
}
if d.StartState == pb.DropletState_ON {

29
poll.go
View File

@ -96,16 +96,27 @@ func (h *HyperT) pollHypervisor() {
for name, t := range h.lastDroplets {
dur := time.Since(t)
if dur > me.hyperPollDelay {
log.Info("droplet has probably powered down", name)
d := findDroplet(name)
if d != nil {
if d.CurrentState != pb.DropletState_UNKNOWN {
d.CurrentState = pb.DropletState_UNKNOWN
log.Info("set state UNKNOWN here", name)
} else {
if dur > time.Minute {
log.Info("UNKNOWN state for more than one minute remove map entry here?", name)
}
if d == nil {
log.Info("droplet has probably powered down", name, "but findDroplet returned nil")
// should delete this from h.lastDroplets
continue
}
// everthing below here is dumb and needs to be rethought
if d.CurrentState != pb.DropletState_UNKNOWN {
d.CurrentState = pb.DropletState_UNKNOWN
log.Info("set state UNKNOWN here", name)
}
if d.CurrentState == pb.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
log.Info("UNKNOWN state for more than one minute remove map entry here?", name)
// 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.CurrentState = pb.DropletState_OFF
}
}
}