diff --git a/dump.go b/dump.go index 9291bb1..511312b 100644 --- a/dump.go +++ b/dump.go @@ -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 { diff --git a/poll.go b/poll.go index c429207..6026b96 100644 --- a/poll.go +++ b/poll.go @@ -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 } } }