compiles. maybe works on some stuff still
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
123f64f56c
commit
748f9b4608
10
create.go
10
create.go
|
@ -35,11 +35,11 @@ func createFilename(dir string, filename string) error {
|
||||||
|
|
||||||
url := urlbase + "/create"
|
url := urlbase + "/create"
|
||||||
|
|
||||||
// body, err := postDropletJSON(url, newDroplet)
|
// body, err := postDropletJSON(url, newDroplet)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// log.Info("postDropletJSON() failed:", err)
|
// log.Info("postDropletJSON() failed:", err)
|
||||||
// return err
|
// return err
|
||||||
// }
|
// }
|
||||||
|
|
||||||
body, err := postDropletWIRE(url, newDroplet)
|
body, err := postDropletWIRE(url, newDroplet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
27
event.go
27
event.go
|
@ -26,6 +26,9 @@ func (h *HyperT) RestartVirtigod() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks if the cluster is ready and stable
|
// checks if the cluster is ready and stable
|
||||||
|
// func (c *Cluster) DropletReady(d *Droplet) (bool, string) {
|
||||||
|
|
||||||
|
/*
|
||||||
func clusterReady() (bool, string) {
|
func clusterReady() (bool, string) {
|
||||||
last := time.Since(me.unstable)
|
last := time.Since(me.unstable)
|
||||||
if last > me.unstableTimeout {
|
if last > me.unstableTimeout {
|
||||||
|
@ -36,30 +39,24 @@ func clusterReady() (bool, string) {
|
||||||
log.Warn("clusterReady() is unstable for", shell.FormatDuration(last))
|
log.Warn("clusterReady() is unstable for", shell.FormatDuration(last))
|
||||||
return false, "clusterReady() is unstable for " + shell.FormatDuration(last)
|
return false, "clusterReady() is unstable for " + shell.FormatDuration(last)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
func dropletReady(d *pb.Droplet) (bool, string) {
|
func dropletReady(d *pb.Droplet) (bool, string) {
|
||||||
if d.CurrentState == pb.DropletState_ON {
|
if d.Current.State == pb.DropletState_ON {
|
||||||
return false, "EVENT start droplet is already ON"
|
return false, "EVENT start droplet is already ON"
|
||||||
}
|
}
|
||||||
if d.Starts > 2 {
|
if d.Current.StartAttempts > 2 {
|
||||||
// reason := "EVENT start droplet has already been started " + d.starts + " times"
|
// reason := "EVENT start droplet has already been started " + d.starts + " times"
|
||||||
return false, fmt.Sprintln("EVENT start droplet has already been started ", d.Starts, " times")
|
return false, fmt.Sprintln("EVENT start droplet has already been started ", d.Starts, " times")
|
||||||
}
|
}
|
||||||
return true, ""
|
return true, ""
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// this must be bool in string because accumulated output is sometimes
|
// this must be bool in string because accumulated output is sometimes
|
||||||
// written to STDOUT, sometimes to http
|
// written to STDOUT, sometimes to http
|
||||||
func (h *HyperT) start(d *pb.Droplet) (bool, string) {
|
func (h *HyperT) start(d *pb.Droplet) (bool, string) {
|
||||||
ready, result := clusterReady()
|
|
||||||
if !ready {
|
|
||||||
return false, result
|
|
||||||
}
|
|
||||||
ready, result = dropletReady(d)
|
|
||||||
if !ready {
|
|
||||||
return false, result
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "http://" + h.pb.Hostname + ":2520/start?start=" + d.Hostname
|
url := "http://" + h.pb.Hostname + ":2520/start?start=" + d.Hostname
|
||||||
var msg string
|
var msg string
|
||||||
var data []byte
|
var data []byte
|
||||||
|
@ -72,15 +69,9 @@ func (h *HyperT) start(d *pb.Droplet) (bool, string) {
|
||||||
log.Info("http post url:", url)
|
log.Info("http post url:", url)
|
||||||
log.Info("http post data:", msg)
|
log.Info("http post data:", msg)
|
||||||
|
|
||||||
result = "EVENT start droplet url: " + url + "\n"
|
result := "EVENT start droplet url: " + url + "\n"
|
||||||
result += "EVENT start droplet response: " + string(req)
|
result += "EVENT start droplet response: " + string(req)
|
||||||
|
|
||||||
// increment the counter for a start attempt working
|
|
||||||
d.Starts += 1
|
|
||||||
|
|
||||||
// mark the cluster as unstable so droplet starts can be throttled
|
|
||||||
me.unstable = time.Now()
|
|
||||||
|
|
||||||
return true, result
|
return true, result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
structs.go
18
structs.go
|
@ -20,15 +20,15 @@ func (b *virtigoT) Enable() {
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type virtigoT struct {
|
type virtigoT struct {
|
||||||
cluster *pb.Cluster // basic cluster settings
|
cluster *pb.Cluster // basic cluster settings
|
||||||
hmap map[*pb.Hypervisor]*HyperT // map to the local struct
|
hmap map[*pb.Hypervisor]*HyperT // map to the local struct
|
||||||
names []string
|
names []string
|
||||||
hypers []*HyperT
|
hypers []*HyperT
|
||||||
killcount int
|
killcount int
|
||||||
unstable time.Time // the last time the cluster was incorrect
|
unstable time.Time // the last time the cluster was incorrect
|
||||||
changed bool
|
changed bool
|
||||||
hyperPollDelay time.Duration // how often to poll the hypervisors
|
// hyperPollDelay time.Duration // how often to poll the hypervisors
|
||||||
unstableTimeout time.Duration // how long a droplet can be unstable until it's declared dead
|
// unstableTimeout time.Duration // how long a droplet can be unstable until it's declared dead
|
||||||
clusterStableDuration time.Duration // how long the cluster must be stable before new droplets can be started
|
clusterStableDuration time.Duration // how long the cluster must be stable before new droplets can be started
|
||||||
missingDropletTimeout time.Duration // how long a droplet can be missing for
|
missingDropletTimeout time.Duration // how long a droplet can be missing for
|
||||||
}
|
}
|
||||||
|
|
25
watchdog.go
25
watchdog.go
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||||
|
@ -37,27 +36,3 @@ func (h *HyperT) sendDirs() {
|
||||||
|
|
||||||
log.Info("EVENT start droplet response: " + string(req))
|
log.Info("EVENT start droplet response: " + string(req))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HyperT) NewWatchdog() {
|
|
||||||
h.dog = time.NewTicker(me.hyperPollDelay)
|
|
||||||
defer h.dog.Stop()
|
|
||||||
done := make(chan bool)
|
|
||||||
/*
|
|
||||||
// this example would exit/destroy the ticker in 10 seconds
|
|
||||||
go func() {
|
|
||||||
time.Sleep(10 * time.Second)
|
|
||||||
done <- true
|
|
||||||
}()
|
|
||||||
*/
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
fmt.Println("Done!")
|
|
||||||
return
|
|
||||||
case t := <-h.dog.C:
|
|
||||||
log.Log(POLL, "Watchdog() ticked", h.pb.Hostname, "Current time: ", t)
|
|
||||||
// h.pollHypervisor()
|
|
||||||
// h.Scan()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue