switched to pb.DropletState enum
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
3ce3a0d7f6
commit
d09f4e25c2
|
@ -25,7 +25,8 @@ func addDomainDroplet(domcfg *libvirtxml.Domain) (*DropletT, error) {
|
|||
d = new(DropletT)
|
||||
|
||||
d.pb = me.cluster.AddDroplet(domcfg.UUID, domcfg.Name, 2, 2*1024*1024)
|
||||
d.pb.StartState = "off"
|
||||
d.pb.StartState = pb.DropletState_OFF
|
||||
d.CurrentState = pb.DropletState_UNKNOWN
|
||||
|
||||
me.droplets = append(me.droplets, d)
|
||||
me.changed = true
|
||||
|
|
5
event.go
5
event.go
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -43,7 +44,7 @@ func clusterReady() (bool, string) {
|
|||
}
|
||||
|
||||
func (d *DropletT) dropletReady() (bool, string) {
|
||||
if d.CurrentState == "ON" {
|
||||
if d.CurrentState == pb.DropletState_ON {
|
||||
return false, "EVENT start droplet is already ON"
|
||||
}
|
||||
if d.starts > 2 {
|
||||
|
@ -86,7 +87,7 @@ func Start(name string) (bool, string) {
|
|||
return false, result
|
||||
}
|
||||
|
||||
if d.CurrentState == "ON" {
|
||||
if d.CurrentState == pb.DropletState_ON {
|
||||
return false, "EVENT start droplet is already ON"
|
||||
}
|
||||
|
||||
|
|
5
http.go
5
http.go
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -23,7 +24,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// is the cluster running what it should?
|
||||
if tmp == "/droplets" {
|
||||
for _, d := range me.droplets {
|
||||
if d.pb.StartState != "ON" {
|
||||
if d.pb.StartState != pb.DropletState_ON {
|
||||
continue
|
||||
}
|
||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||
|
@ -33,7 +34,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
} else {
|
||||
hname = d.h.pb.Hostname
|
||||
}
|
||||
if d.CurrentState != "ON" {
|
||||
if d.CurrentState != pb.DropletState_ON {
|
||||
fmt.Fprintln(w, "BAD STATE ", d.pb.Hostname, hname, "(", d.pb.StartState, "vs", d.CurrentState, ")", shell.FormatDuration(dur))
|
||||
} else {
|
||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||
|
|
13
poll.go
13
poll.go
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -38,14 +39,14 @@ func (h *HyperT) pollHypervisor() {
|
|||
d.pb.Hostname = name
|
||||
d.h = h
|
||||
d.lastpoll = time.Now()
|
||||
d.CurrentState = "ON"
|
||||
d.CurrentState = pb.DropletState_ON
|
||||
me.droplets = append(me.droplets, d)
|
||||
log.Log(EVENT, name, "IS NEW. ADDED ON", h.pb.Hostname)
|
||||
}
|
||||
log.Log(INFO, "ALREADY RECORDED", d.pb.Hostname)
|
||||
|
||||
// update the status to ON and the last polled value
|
||||
d.CurrentState = "ON"
|
||||
d.CurrentState = pb.DropletState_ON
|
||||
d.lastpoll = time.Now()
|
||||
|
||||
if d.h == nil {
|
||||
|
@ -108,11 +109,11 @@ func clusterHealthy() (bool, string) {
|
|||
|
||||
for _, d := range me.droplets {
|
||||
total += 1
|
||||
if d.pb.StartState != "ON" {
|
||||
if d.pb.StartState != pb.DropletState_ON {
|
||||
continue
|
||||
}
|
||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||
if d.CurrentState == "" {
|
||||
if d.CurrentState == pb.DropletState_UNKNOWN {
|
||||
// log.Info("SKIP. hostname has not been polled yet", d.pb.Hostname, d.hname)
|
||||
unknown += 1
|
||||
unknownList = append(unknownList, d.pb.Hostname)
|
||||
|
@ -122,7 +123,7 @@ func clusterHealthy() (bool, string) {
|
|||
if d.h != nil {
|
||||
hname = d.h.pb.Hostname
|
||||
}
|
||||
if d.CurrentState != "ON" {
|
||||
if d.CurrentState != pb.DropletState_ON {
|
||||
log.Info("BAD STATE", d.pb.StartState, d.pb.Hostname, hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur))
|
||||
good = false
|
||||
failed += 1
|
||||
|
@ -131,7 +132,7 @@ func clusterHealthy() (bool, string) {
|
|||
if dur > time.Minute {
|
||||
log.Info("GOOD STATE MISSING", d.pb.Hostname, hname, shell.FormatDuration(dur))
|
||||
good = false
|
||||
d.CurrentState = "MISSING"
|
||||
d.CurrentState = pb.DropletState_UNKNOWN
|
||||
failed += 1
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ type DropletT struct {
|
|||
pb *pb.Droplet // the Droplet protobuf
|
||||
xml *libvirtxml.Domain // a xml representation from libvirt
|
||||
h *HyperT // the hypervisor it's currently running on
|
||||
CurrentState string // what the state of the droplet is ACTUALLY IS
|
||||
CurrentState pb.DropletState // what the state of the droplet is ACTUALLY IS
|
||||
lastpoll time.Time // the last time the droplet was seen running
|
||||
starts int // how many times a start event has been attempted
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue