ready to trigger importDomain()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-31 17:00:34 -05:00
parent b28ae96cd4
commit 3562fc780e
1 changed files with 23 additions and 17 deletions

40
poll.go
View File

@ -36,15 +36,18 @@ func (h *HyperT) pollHypervisor() {
if state == "OFF" {
d := me.cluster.FindDropletByName(name)
if d == nil {
log.Log(WARN, "locally defined domain:", h.pb.Hostname, fields)
log.Log(WARN, "neeed to add a local droplet protobuf")
log.Log(WARN, "local", h.pb.Hostname, name, "locally defined domain")
log.Log(WARN, "local", h.pb.Hostname, name, "Running AddDropletLocal()")
log.Log(WARN, "local", h.pb.Hostname, name, "Running AddDropletLocal()")
log.Log(WARN, "local", h.pb.Hostname, name, "Running AddDropletLocal()")
me.cluster.AddDropletLocal(name, h.pb.Hostname)
return
}
if d.LocalOnly == "" {
log.Log(WARN, "ready to import", d.Hostname, "from", h.pb.Hostname)
log.Log(WARN, "local", h.pb.Hostname, name, "duplicate defined (need to resolve this)")
continue
}
log.Log(WARN, "duplicate local droplet", h.pb.Hostname, fields, "need to resolve this")
log.Log(WARN, "local", h.pb.Hostname, name, "ready to import from hypervisor")
continue
}
h.lastDroplets[name] = time.Now()
@ -156,23 +159,16 @@ func uptimeCheck() (bool, string) {
continue
}
dur := time.Since(d.Current.LastPoll.AsTime()) // Calculate the elapsed time
if d.Current.State == pb.DropletState_UNKNOWN {
// log.Info("SKIP. hostname has not been polled yet", d.Hostname, d.hname)
unknown += 1
unknownList = append(unknownList, d.Hostname)
continue
}
var hname string
if d.Current.Hypervisor != "" {
hname = d.Current.Hypervisor
}
if d.Current.State != pb.DropletState_ON {
log.Info("BAD STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, shell.FormatDuration(dur))
good = false
failed += 1
missing = append(missing, d)
} else {
dur := time.Since(d.Current.LastPoll.AsTime()) // Calculate the elapsed time
switch d.Current.State {
case pb.DropletState_UNKNOWN:
// log.Info("SKIP. hostname has not been polled yet", d.Hostname, d.hname)
unknown += 1
unknownList = append(unknownList, d.Hostname)
case pb.DropletState_ON:
if dur > me.missingDropletTimeout {
log.Info("GOOD STATE MISSING", d.Hostname, hname, shell.FormatDuration(dur))
good = false
@ -188,6 +184,16 @@ func uptimeCheck() (bool, string) {
}
working += 1
// log.Info("GOOD STATE ON", d.Hostname, d.hname, "dur =", l)
case pb.DropletState_OFF:
log.Info("OFF STATE", d.StartState, d.Hostname, hname, shell.FormatDuration(dur))
good = false
failed += 1
// missing = append(missing, d)
default:
log.Info("WTF STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, shell.FormatDuration(dur))
good = false
failed += 1
missing = append(missing, d)
}
}
var summary string = "("