summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configfiles.go14
-rw-r--r--event.go4
-rw-r--r--http.go6
-rw-r--r--main.go2
-rw-r--r--poll.go4
-rw-r--r--structs.go6
6 files changed, 17 insertions, 19 deletions
diff --git a/configfiles.go b/configfiles.go
index 927f328..dad2421 100644
--- a/configfiles.go
+++ b/configfiles.go
@@ -61,17 +61,17 @@ func readDropletFile(filename string) {
if d == nil {
// this is a new unknown droplet (not in the config file)
d = new(DropletT)
+ d.pb = me.cluster.AddDroplet(name, 16, 256)
if len(fields) > 1 && fields[1] != "ON" {
- d.ConfigState = "OFF"
+ d.pb.StartState = "OFF"
} else {
- d.ConfigState = "ON"
+ d.pb.StartState = "ON"
}
if len(fields) >= 3 {
d.hyperPreferred = fields[2]
}
- d.pb = me.cluster.AddDroplet(name, 16, 256)
me.droplets = append(me.droplets, d)
- log.Log(EVENT, "config new droplet", d.pb.Hostname, d.ConfigState, d.hyperPreferred)
+ log.Log(EVENT, "config new droplet", d.pb.Hostname, d.pb.StartState, d.hyperPreferred)
} else {
log.Info("not sure what to do here. duplicate droplet", name, "in config file")
}
@@ -99,9 +99,9 @@ func readHypervisorFile(filename string) {
name := fields[0]
h := addHypervisor(name)
if len(fields) < 2 || fields[1] != "active" {
- h.Active = false
+ h.pb.Active = false
} else {
- h.Active = true
+ h.pb.Active = true
}
}
}
@@ -115,13 +115,13 @@ func addHypervisor(name string) *HyperT {
}
log.Log(EVENT, "config new hypervisor", name)
h = new(HyperT)
- h.Autoscan = true
h.Delay = 5 * time.Second
h.lastpoll = time.Now()
h.Scan = func() {
h.pollHypervisor()
}
h.pb = me.cluster.AddHypervisor(name, 16, 256)
+ h.pb.Autoscan = true
me.hypers = append(me.hypers, h)
return h
}
diff --git a/event.go b/event.go
index 05f8c7f..0150994 100644
--- a/event.go
+++ b/event.go
@@ -100,14 +100,14 @@ func Start(name string) (bool, string) {
// make the list of hypervisors that are active and can start new droplets
var pool []*HyperT
for _, h := range me.hypers {
- result += fmt.Sprintln("could start droplet on", name, "on", h.pb.Hostname, h.Active)
+ result += fmt.Sprintln("could start droplet on", name, "on", h.pb.Hostname, h.pb.Active)
if d.hyperPreferred == h.pb.Hostname {
// the config file says this droplet should run on this hypervisor
a, b := h.Start(d)
return a, result + b
}
- if h.Active != true {
+ if h.pb.Active != true {
continue
}
pool = append(pool, h)
diff --git a/http.go b/http.go
index 158d346..be4a8c0 100644
--- a/http.go
+++ b/http.go
@@ -23,12 +23,12 @@ 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.ConfigState != "ON" {
+ if d.pb.StartState != "ON" {
continue
}
dur := time.Since(d.lastpoll) // Calculate the elapsed time
if d.CurrentState != "ON" {
- fmt.Fprintln(w, "BAD STATE ", d.pb.Hostname, d.hname, "(", d.ConfigState, "vs", d.CurrentState, ")", shell.FormatDuration(dur))
+ fmt.Fprintln(w, "BAD STATE ", d.pb.Hostname, d.hname, "(", d.pb.StartState, "vs", d.CurrentState, ")", shell.FormatDuration(dur))
} else {
dur := time.Since(d.lastpoll) // Calculate the elapsed time
fmt.Fprintln(w, "GOOD STATE ON", d.pb.Hostname, d.hname, shell.FormatDuration(dur))
@@ -65,7 +65,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
}
// l := shell.FormatDuration(dur)
// log.Warn("HOST =", h.pb.Hostname, "Last poll =", l)
- //if d.ConfigState != "ON" {
+ //if d.pb.StartState != "ON" {
// continue
//}
// dur := time.Since(d.lastpoll) // Calculate the elapsed time
diff --git a/main.go b/main.go
index a1de774..3bd152a 100644
--- a/main.go
+++ b/main.go
@@ -45,7 +45,7 @@ func main() {
continue
}
h = addHypervisor(name)
- h.Active = true
+ h.pb.Active = true
}
if argv.Start != "" {
diff --git a/poll.go b/poll.go
index cf39378..41f0349 100644
--- a/poll.go
+++ b/poll.go
@@ -105,7 +105,7 @@ func clusterHealthy() (bool, string) {
for _, d := range me.droplets {
total += 1
- if d.ConfigState != "ON" {
+ if d.pb.StartState != "ON" {
continue
}
dur := time.Since(d.lastpoll) // Calculate the elapsed time
@@ -116,7 +116,7 @@ func clusterHealthy() (bool, string) {
continue
}
if d.CurrentState != "ON" {
- log.Info("BAD STATE", d.ConfigState, d.pb.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur))
+ log.Info("BAD STATE", d.pb.StartState, d.pb.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur))
good = false
failed += 1
} else {
diff --git a/structs.go b/structs.go
index d67f7c0..25a6169 100644
--- a/structs.go
+++ b/structs.go
@@ -31,19 +31,17 @@ type virtigoT struct {
// the stuff that is needed for a hypervisor
type HyperT struct {
pb *pb.Hypervisor // the Hypervisor protobuf
- Active bool // is allowed to start new droplets
- Scan func() // the function to run to scan the hypervisor
- Autoscan bool // to scan or not to scan
Delay time.Duration // how often to poll the hypervisor
Dog *time.Ticker // the watchdog timer itself
lastpoll time.Time // the last time the hypervisor polled
killcount int
+ Scan func() // the function to run to scan the hypervisor
}
// the stuff that is needed for a hypervisor
type DropletT struct {
pb *pb.Droplet // the Droplet protobuf
- ConfigState string // what the state of the droplet is SUPPOSED TO BE
+ // ConfigState string // what the state of the droplet is SUPPOSED TO BE
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