works again. I fucking deleted the kuma check

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-26 09:33:31 -05:00
parent b4518e8b82
commit 161bfe395e
2 changed files with 15 additions and 18 deletions

View File

@ -144,7 +144,7 @@ func main() {
h.lastpoll = time.Now() h.lastpoll = time.Now()
me.hmap[pbh] = h me.hmap[pbh] = h
// me.hypers = append(me.hypers, h) me.hypers = append(me.hypers, h)
log.Log(EVENT, "config new hypervisors", h.pb.Hostname) log.Log(EVENT, "config new hypervisors", h.pb.Hostname)
} }

31
poll.go
View File

@ -39,36 +39,35 @@ func (h *HyperT) pollHypervisor() {
} }
log.Log(INFO, "ALREADY RECORDED", d.Hostname) log.Log(INFO, "ALREADY RECORDED", d.Hostname)
// update the status to ON and the last polled value // update the status to ON
d.CurrentState = pb.DropletState_ON d.CurrentState = pb.DropletState_ON
// set the LastPoll time to now
now := time.Now() now := time.Now()
d.LastPoll = timestamppb.New(now) d.LastPoll = timestamppb.New(now)
var cur *HyperT if d.CurrentHypervisor == "" {
// cur := find(d.CurrentHypervisor)
if cur == nil {
// this means the droplet was in the config file // this means the droplet was in the config file
// but this is the first time it's shown up as running // 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 // this should mean a droplet is running where the config file says it probably should be running
if d.PreferredHypervisor == h.pb.Hostname { if d.PreferredHypervisor == h.pb.Hostname {
log.Log(EVENT, "new droplet", d.Hostname, "(matches config hypervisor", h.pb.Hostname+")") log.Log(EVENT, "poll shows new droplet", d.Hostname, "(matches config hypervisor", h.pb.Hostname+")")
cur = h d.CurrentHypervisor = h.pb.Hostname
continue continue
} }
log.Log(EVENT, "new droplet", d.Hostname, "on", h.pb.Hostname, "(in config file without preferred hypervisor)") log.Log(EVENT, "poll shows new droplet", d.Hostname, "on", h.pb.Hostname, "(in config file without preferred hypervisor)")
cur = h d.CurrentHypervisor = h.pb.Hostname
continue continue
} }
// this means the droplet is still where it was before // this means the droplet has moved
if cur.pb.Hostname != h.pb.Hostname { if d.CurrentHypervisor != h.pb.Hostname {
log.Log(EVENT, "droplet", d.Hostname, "moved to", h.pb.Hostname) log.Log(EVENT, "droplet", d.Hostname, "moved to", h.pb.Hostname)
continue continue
} }
cur = h d.CurrentHypervisor = h.pb.Hostname
} }
continue continue
} }
@ -77,13 +76,11 @@ func (h *HyperT) pollHypervisor() {
} }
func findDroplet(name string) *pb.Droplet { func findDroplet(name string) *pb.Droplet {
/* for _, d := range me.cluster.Droplets {
for _, d := range me.droplets { if d.Hostname == name {
if d.Hostname == name { return d
return d
}
} }
*/ }
return nil return nil
} }