diff options
Diffstat (limited to 'poll.go')
| -rw-r--r-- | poll.go | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -36,7 +36,7 @@ func (h *HyperT) pollHypervisor() { // this is a new unknown droplet (not in the config file) d = new(DropletT) d.pb.Hostname = name - d.hname = h.pb.Hostname + d.h = h d.lastpoll = time.Now() d.CurrentState = "ON" me.droplets = append(me.droplets, d) @@ -49,24 +49,24 @@ func (h *HyperT) pollHypervisor() { d.lastpoll = time.Now() // this means the droplet is still where it was before - if d.hname == h.pb.Hostname { + if d.h.pb.Hostname == h.pb.Hostname { continue } - if d.hname == "" { + if d.h == nil { // this means the droplet was in the config file // but this is the first time it's shown up as running // this should mean a droplet is running where the config file says it probably should be running - if d.hyperPreferred == h.pb.Hostname { + if d.pb.PreferredHypervisor == h.pb.Hostname { log.Log(EVENT, "new droplet", d.pb.Hostname, "(matches config hypervisor", h.pb.Hostname+")") - d.hname = h.pb.Hostname + d.h = h continue } log.Log(EVENT, "new droplet", d.pb.Hostname, "on", h.pb.Hostname, "(in config file without preferred hypervisor)") } - d.hname = h.pb.Hostname + d.h = h } continue } @@ -115,14 +115,18 @@ func clusterHealthy() (bool, string) { unknownList = append(unknownList, d.pb.Hostname) continue } + var hname string + if d.h != nil { + hname = d.h.pb.Hostname + } if d.CurrentState != "ON" { - log.Info("BAD STATE", d.pb.StartState, d.pb.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur)) + log.Info("BAD STATE", d.pb.StartState, d.pb.Hostname, hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur)) good = false failed += 1 } else { dur := time.Since(d.lastpoll) // Calculate the elapsed time if dur > time.Minute { - log.Info("GOOD STATE MISSING", d.pb.Hostname, d.hname, shell.FormatDuration(dur)) + log.Info("GOOD STATE MISSING", d.pb.Hostname, hname, shell.FormatDuration(dur)) good = false d.CurrentState = "MISSING" failed += 1 |
