compiles and runs
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
3ba9a5da20
commit
b1a943fa3d
|
@ -68,10 +68,10 @@ func readDropletFile(filename string) {
|
||||||
d.pb.StartState = "ON"
|
d.pb.StartState = "ON"
|
||||||
}
|
}
|
||||||
if len(fields) >= 3 {
|
if len(fields) >= 3 {
|
||||||
d.hyperPreferred = fields[2]
|
d.pb.PreferredHypervisor = fields[2]
|
||||||
}
|
}
|
||||||
me.droplets = append(me.droplets, d)
|
me.droplets = append(me.droplets, d)
|
||||||
log.Log(EVENT, "config new droplet", d.pb.Hostname, d.pb.StartState, d.hyperPreferred)
|
log.Log(EVENT, "config new droplet", d.pb.Hostname, d.pb.StartState, d.pb.PreferredHypervisor)
|
||||||
} else {
|
} else {
|
||||||
log.Info("not sure what to do here. duplicate droplet", name, "in config file")
|
log.Info("not sure what to do here. duplicate droplet", name, "in config file")
|
||||||
}
|
}
|
||||||
|
|
2
event.go
2
event.go
|
@ -101,7 +101,7 @@ func Start(name string) (bool, string) {
|
||||||
var pool []*HyperT
|
var pool []*HyperT
|
||||||
for _, h := range me.hypers {
|
for _, h := range me.hypers {
|
||||||
result += fmt.Sprintln("could start droplet on", name, "on", h.pb.Hostname, h.pb.Active)
|
result += fmt.Sprintln("could start droplet on", name, "on", h.pb.Hostname, h.pb.Active)
|
||||||
if d.hyperPreferred == h.pb.Hostname {
|
if d.pb.PreferredHypervisor == h.pb.Hostname {
|
||||||
// the config file says this droplet should run on this hypervisor
|
// the config file says this droplet should run on this hypervisor
|
||||||
a, b := h.Start(d)
|
a, b := h.Start(d)
|
||||||
return a, result + b
|
return a, result + b
|
||||||
|
|
10
http.go
10
http.go
|
@ -27,11 +27,17 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||||
|
var hname string
|
||||||
|
if d.h == nil {
|
||||||
|
hname = ""
|
||||||
|
} else {
|
||||||
|
hname = d.h.pb.Hostname
|
||||||
|
}
|
||||||
if d.CurrentState != "ON" {
|
if d.CurrentState != "ON" {
|
||||||
fmt.Fprintln(w, "BAD STATE ", d.pb.Hostname, d.hname, "(", d.pb.StartState, "vs", d.CurrentState, ")", shell.FormatDuration(dur))
|
fmt.Fprintln(w, "BAD STATE ", d.pb.Hostname, hname, "(", d.pb.StartState, "vs", d.CurrentState, ")", shell.FormatDuration(dur))
|
||||||
} else {
|
} else {
|
||||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||||
fmt.Fprintln(w, "GOOD STATE ON", d.pb.Hostname, d.hname, shell.FormatDuration(dur))
|
fmt.Fprintln(w, "GOOD STATE ON", d.pb.Hostname, hname, shell.FormatDuration(dur))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
20
poll.go
20
poll.go
|
@ -36,7 +36,7 @@ func (h *HyperT) pollHypervisor() {
|
||||||
// this is a new unknown droplet (not in the config file)
|
// this is a new unknown droplet (not in the config file)
|
||||||
d = new(DropletT)
|
d = new(DropletT)
|
||||||
d.pb.Hostname = name
|
d.pb.Hostname = name
|
||||||
d.hname = h.pb.Hostname
|
d.h = h
|
||||||
d.lastpoll = time.Now()
|
d.lastpoll = time.Now()
|
||||||
d.CurrentState = "ON"
|
d.CurrentState = "ON"
|
||||||
me.droplets = append(me.droplets, d)
|
me.droplets = append(me.droplets, d)
|
||||||
|
@ -49,24 +49,24 @@ func (h *HyperT) pollHypervisor() {
|
||||||
d.lastpoll = time.Now()
|
d.lastpoll = time.Now()
|
||||||
|
|
||||||
// this means the droplet is still where it was before
|
// 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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.hname == "" {
|
if d.h == 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.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+")")
|
log.Log(EVENT, "new droplet", d.pb.Hostname, "(matches config hypervisor", h.pb.Hostname+")")
|
||||||
d.hname = h.pb.Hostname
|
d.h = h
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Log(EVENT, "new droplet", d.pb.Hostname, "on", h.pb.Hostname, "(in config file without preferred hypervisor)")
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
@ -115,14 +115,18 @@ func clusterHealthy() (bool, string) {
|
||||||
unknownList = append(unknownList, d.pb.Hostname)
|
unknownList = append(unknownList, d.pb.Hostname)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
var hname string
|
||||||
|
if d.h != nil {
|
||||||
|
hname = d.h.pb.Hostname
|
||||||
|
}
|
||||||
if d.CurrentState != "ON" {
|
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
|
good = false
|
||||||
failed += 1
|
failed += 1
|
||||||
} else {
|
} else {
|
||||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||||
if dur > time.Minute {
|
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
|
good = false
|
||||||
d.CurrentState = "MISSING"
|
d.CurrentState = "MISSING"
|
||||||
failed += 1
|
failed += 1
|
||||||
|
|
|
@ -41,10 +41,7 @@ type HyperT struct {
|
||||||
// the stuff that is needed for a hypervisor
|
// the stuff that is needed for a hypervisor
|
||||||
type DropletT struct {
|
type DropletT struct {
|
||||||
pb *pb.Droplet // the Droplet protobuf
|
pb *pb.Droplet // the Droplet protobuf
|
||||||
// ConfigState string // what the state of the droplet is SUPPOSED TO BE
|
|
||||||
CurrentState string // what the state of the droplet is ACTUALLY IS
|
CurrentState string // what the state of the droplet is ACTUALLY IS
|
||||||
hyperPreferred string // the hypervisor to prefer to run the droplet on
|
|
||||||
hname string // the hypervisor it's currently running on
|
|
||||||
h *HyperT // the hypervisor it's currently running on
|
h *HyperT // the hypervisor it's currently running on
|
||||||
lastpoll time.Time // the last time the droplet was seen running
|
lastpoll time.Time // the last time the droplet was seen running
|
||||||
starts int // how many times a start event has been attempted
|
starts int // how many times a start event has been attempted
|
||||||
|
|
Loading…
Reference in New Issue