summaryrefslogtreecommitdiff
path: root/poll.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-28 08:06:14 -0500
committerJeff Carr <[email protected]>2024-10-28 08:06:14 -0500
commitc12d3a2dbbe31b63a9ab4f2341bc407645d7e08b (patch)
tree991aec4b26378073e3f75f21037f603756da6076 /poll.go
parentde5f5c6a85b14810cca87bd89e439ce52698f965 (diff)
continuing work on tracking droplet state
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'poll.go')
-rw-r--r--poll.go29
1 files changed, 20 insertions, 9 deletions
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
}
}
}