diff options
| -rw-r--r-- | configfiles.go | 8 | ||||
| -rw-r--r-- | http.go | 6 | ||||
| -rw-r--r-- | main.go | 11 | ||||
| -rw-r--r-- | poll.go | 7 | ||||
| -rw-r--r-- | structs.go | 2 |
5 files changed, 19 insertions, 15 deletions
diff --git a/configfiles.go b/configfiles.go index 1bdf153..f758058 100644 --- a/configfiles.go +++ b/configfiles.go @@ -33,15 +33,15 @@ func readDropletFile(filename string) { d = new(DropletT) d.Hostname = name if len(fields) > 1 && fields[1] != "ON" { - d.State = "OFF" + d.ConfigState = "OFF" } else { - d.State = "ON" + d.ConfigState = "ON" } if len(fields) >= 3 { d.hyperPreferred = fields[2] } me.droplets = append(me.droplets, d) - log.Log(EVENT, "NEW CONFIG DROPLET", d.Hostname, d.State, d.hyperPreferred) + log.Log(EVENT, "config new droplet", d.Hostname, d.ConfigState, d.hyperPreferred) } else { log.Info("not sure what to do here. duplicate droplet", name, "in config file") } @@ -83,7 +83,7 @@ func addHypervisor(name string) *HyperT { log.Info("not sure what to do here. duplicate hypervisor", name, "in config file") return h } - log.Log(EVENT, "Adding new hypervisor", name) + log.Log(EVENT, "config new hypervisor", name) h = new(HyperT) h.Hostname = name h.Autoscan = true @@ -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.State != "ON" { + if d.ConfigState != "ON" { continue } dur := time.Since(d.lastpoll) // Calculate the elapsed time if d.CurrentState != "ON" { - fmt.Fprintln(w, "BAD STATE ", d.Hostname, d.hname, "(", d.State, "vs", d.CurrentState, ")", shell.FormatDuration(dur)) + fmt.Fprintln(w, "BAD STATE ", d.Hostname, d.hname, "(", d.ConfigState, "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)) @@ -65,7 +65,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { } // l := shell.FormatDuration(dur) // log.Warn("HOST =", h.Hostname, "Last poll =", l) - //if d.State != "ON" { + //if d.ConfigState != "ON" { // continue //} // dur := time.Since(d.lastpoll) // Calculate the elapsed time @@ -34,9 +34,14 @@ func main() { // initialize the grid as unstable me.unstable = time.Now() - log.Info("create cluser for", argv.Hosts) + log.Info("command line hypervisors:", argv.Hosts) for _, name := range argv.Hosts { - h := addHypervisor(name) + h := findHypervisor(name) + if h != nil { + log.Info("command line hypervisor", name, "already in config file") + continue + } + h = addHypervisor(name) h.Active = true } @@ -52,7 +57,7 @@ func main() { // start the watchdog polling for each hypervisor for _, h := range me.hypers { - log.Info("starting watchdog here for hostname =", h.Hostname) + log.Info("starting polling on", h.Hostname) go h.NewWatchdog() } @@ -64,8 +64,7 @@ func (h *HyperT) pollHypervisor() { 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) + log.Log(EVENT, "new droplet", d.Hostname, "on", h.Hostname, "(in config file without preferred hypervisor)") } d.hname = h.Hostname } @@ -106,7 +105,7 @@ func clusterHealthy() (bool, string) { for _, d := range me.droplets { total += 1 - if d.State != "ON" { + if d.ConfigState != "ON" { continue } dur := time.Since(d.lastpoll) // Calculate the elapsed time @@ -117,7 +116,7 @@ func clusterHealthy() (bool, string) { continue } if d.CurrentState != "ON" { - log.Info("BAD STATE", d.State, d.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur)) + log.Info("BAD STATE", d.ConfigState, d.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur)) good = false failed += 1 } else { @@ -38,7 +38,7 @@ type HyperT struct { // the stuff that is needed for a hypervisor type DropletT struct { Hostname string // the name of the virtual machine. should be unique (probably enforce this forever) - State 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 |
