working further on handling vm ghosting

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-01 10:23:49 -05:00
parent 8b588eeba5
commit 2c1c3482fe
1 changed files with 12 additions and 3 deletions

15
poll.go
View File

@ -108,26 +108,35 @@ func (h *HyperT) pollHypervisor() {
d.Current.Hypervisor = h.pb.Hostname
}
}
// these are the droplets that don't exist anymore on this hypervisor
// this should mean you ran shutdown within domU
for name, t := range h.lastDroplets {
dur := time.Since(t)
if dur > me.hyperPollDelay {
d := me.cluster.FindDropletByName(name)
header := d.SprintHeader()
if d == nil {
log.Info("droplet has probably powered down", name, "but findDroplet returned nil")
log.Info(header, "droplet has probably powered down", name, "but findDroplet returned nil")
// should delete this from h.lastDroplets
continue
}
if d.Current.State == pb.DropletState_OFF {
log.Info(header, "droplet timed out and is off. remove from h.lastDroplets[] slice")
continue
}
// everthing below here is dumb and needs to be rethought
if d.Current.State != pb.DropletState_UNKNOWN {
d.SetState(pb.DropletState_UNKNOWN)
log.Info("set state UNKNOWN here", name)
log.Info(header, "set state UNKNOWN here", name)
}
if d.Current.State == 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
s := pb.FormatDuration(dur)
log.Info("UNKNOWN state for more than 2 minutes (clearing out ?)", name, s)
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