diff options
| author | Jeff Carr <[email protected]> | 2024-10-27 11:02:50 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-27 11:02:50 -0500 |
| commit | 8fc2fbd9c9a6f05852cd597b246f0b4e634af7d7 (patch) | |
| tree | 707c6044781eb4ef1f3ed9c4b756f6e605e4b6c8 /poll.go | |
| parent | d38865a6cf3d9e11803e9f565a0dd0c763de479d (diff) | |
track droplets reported from each hypervisor
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'poll.go')
| -rw-r--r-- | poll.go | 52 |
1 files changed, 31 insertions, 21 deletions
@@ -18,6 +18,7 @@ func (h *HyperT) pollHypervisor() { if s == nil { return } + var bytesSplice []byte bytesSplice = s.Bytes() // fmt.Fprintln(w, string(bytesSplice)) @@ -31,12 +32,26 @@ func (h *HyperT) pollHypervisor() { } state := fields[0] name := fields[1] + if state == "OFF" { + // skip locally defined libvirt vms + continue + } + h.lastDroplets[name] = time.Now() + // if _, ok := h.lastDroplets[name]; ok { + // h.lastDroplets[name] = time.Now() + // } + + // try the protobuf + d := findDroplet(name) + if d == nil { + // not sure whawt now? + log.Log(WARN, name, "is unknown on", h.pb.Hostname, "state =", state) + log.Log(WARN, name, "this vm was probably started by hand using virtsh") + log.Log(WARN, name, "todo: import vm from libvrit") + continue + } if state == "ON" { log.Log(POLL, h.pb.Hostname, "STATE:", state, "HOST:", name, "rest:", fields[2:]) - d := findDroplet(name) - if d == nil { - // not sure whawt now? - } log.Log(INFO, "ALREADY RECORDED", d.Hostname) // update the status to ON @@ -69,30 +84,25 @@ func (h *HyperT) pollHypervisor() { } d.CurrentHypervisor = h.pb.Hostname } - continue } - h.lastpoll = time.Now() - h.killcount = 0 // poll worked. reset killcount -} - -/* -func findHypervisor(name string) *HyperT { - if h, ok := me.hmap[name]; ok { - return h - } - return nil - for _, h := range me.hypers { - if h.pb.Hostname == name { - return h + 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 { + d.CurrentState = pb.DropletState_UNKNOWN + log.Info("set state UNKNOWN here", name) + } } } - return nil + h.lastpoll = time.Now() + h.killcount = 0 // poll worked. reset killcount } -*/ // check the state of the cluster and return a string // that is intended to be sent to an uptime monitor like Kuma -func clusterHealthy() (bool, string) { +func uptimeCheck() (bool, string) { var good bool = true var total int var working int |
