clean up logging of initial scan of droplets
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
25b0709668
commit
c3a69690ee
1
README
1
README
|
@ -16,6 +16,7 @@ Notes & Goals:
|
|||
|
||||
* Be super easy to use.
|
||||
* Automatically map access to serial and graphical consoles
|
||||
* Only temporarily generate libvirt XML files for virsh create
|
||||
* This is intended for managing Virtual Machines, not for containers
|
||||
* This often uses the DO nomenclature 'droplets' instead of 'virtual machines' or 'domU'
|
||||
* Every droplet is considered hostile
|
||||
|
|
3
event.go
3
event.go
|
@ -23,6 +23,9 @@ func (h *HyperT) RestartDaemon() {
|
|||
dur := time.Since(h.lastpoll) // Calculate the elapsed time
|
||||
log.Info("KILLED DAEMON", h.Hostname, shell.FormatDuration(dur), "curl", url)
|
||||
me.killcount += 1
|
||||
|
||||
// mark the cluster as unstable so droplet starts can be throttled
|
||||
me.unstable = time.Now()
|
||||
}
|
||||
|
||||
var stableTimeout time.Duration = 43 * time.Second
|
||||
|
|
2
http.go
2
http.go
|
@ -28,7 +28,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||
if d.CurrentState != "ON" {
|
||||
fmt.Fprintln(w, "BAD STATE ", d.Hostname, "State =", d.State, "CurrentState =", d.CurrentState, shell.FormatDuration(dur))
|
||||
fmt.Fprintln(w, "BAD STATE ", d.Hostname, d.hname, "(", d.State, "vs", d.CurrentState, ")", shell.FormatDuration(dur))
|
||||
} else {
|
||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||
fmt.Fprintln(w, "GOOD STATE ON", d.Hostname, d.hname, shell.FormatDuration(dur))
|
||||
|
|
49
poll.go
49
poll.go
|
@ -32,29 +32,44 @@ func (h *HyperT) pollHypervisor() {
|
|||
if state == "ON" {
|
||||
log.Log(POLL, h.Hostname, "STATE:", state, "HOST:", name, "rest:", fields[2:])
|
||||
d := findDroplet(name)
|
||||
if d != nil {
|
||||
log.Log(INFO, "ALREADY RECORDED", d.Hostname)
|
||||
if d == nil {
|
||||
// this is a new unknown droplet (not in the config file)
|
||||
d = new(DropletT)
|
||||
d.Hostname = name
|
||||
d.hname = h.Hostname
|
||||
d.lastpoll = time.Now()
|
||||
d.CurrentState = "ON"
|
||||
// log.Info("ALREADY RECORDED", d.Hostname, d.lastpoll)
|
||||
if d.hname == "" {
|
||||
log.Log(EVENT, "DROPLET", d.Hostname, "PROBABLY WAS NEVER POLLED YET")
|
||||
}
|
||||
if d.hname != h.Hostname {
|
||||
log.Log(EVENT, "DROPLET", d.Hostname, "MOVED FROM", d.hname, "TO", h.Hostname)
|
||||
d.hname = h.Hostname
|
||||
}
|
||||
me.droplets = append(me.droplets, d)
|
||||
log.Log(EVENT, name, "IS NEW. ADDED ON", h.Hostname)
|
||||
}
|
||||
log.Log(INFO, "ALREADY RECORDED", d.Hostname)
|
||||
|
||||
// update the status to ON and the last polled value
|
||||
d.CurrentState = "ON"
|
||||
d.lastpoll = time.Now()
|
||||
|
||||
// this means the droplet is still where it was before
|
||||
if d.hname == h.Hostname {
|
||||
continue
|
||||
}
|
||||
// this is a new unknown droplet (not in the config file)
|
||||
d = new(DropletT)
|
||||
d.Hostname = name
|
||||
|
||||
if d.hname == "" {
|
||||
// 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.Hostname {
|
||||
log.Log(EVENT, "new droplet", d.Hostname, "(matches config hypervisor", h.Hostname + ")")
|
||||
d.hname = h.Hostname
|
||||
continue
|
||||
}
|
||||
|
||||
log.Log(EVENT, "new droplet", d.Hostname, "was not in the config file")
|
||||
log.Log(EVENT, "new droplet", d.Hostname, "moved", d.hname, h.Hostname, "config file hypervisor =", d.hname)
|
||||
}
|
||||
d.hname = h.Hostname
|
||||
d.lastpoll = time.Now()
|
||||
d.CurrentState = "ON"
|
||||
me.droplets = append(me.droplets, d)
|
||||
log.Log(EVENT, name, "IS NEW. ADDED ON", h.Hostname)
|
||||
}
|
||||
continue
|
||||
}
|
||||
h.lastpoll = time.Now()
|
||||
h.killcount = 0 // poll worked. reset killcount
|
||||
|
|
Loading…
Reference in New Issue