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"
|
||||
|
||||
// body, err := postDropletJSON(url, newDroplet)
|
||||
// if err != nil {
|
||||
// log.Info("postDropletJSON() failed:", err)
|
||||
// return err
|
||||
// }
|
||||
// body, err := postDropletJSON(url, newDroplet)
|
||||
// if err != nil {
|
||||
// log.Info("postDropletJSON() failed:", err)
|
||||
// return err
|
||||
// }
|
||||
|
||||
body, err := postDropletWIRE(url, newDroplet)
|
||||
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
|
||||
// func (c *Cluster) DropletReady(d *Droplet) (bool, string) {
|
||||
|
||||
/*
|
||||
func clusterReady() (bool, string) {
|
||||
last := time.Since(me.unstable)
|
||||
if last > me.unstableTimeout {
|
||||
|
@ -36,30 +39,24 @@ func clusterReady() (bool, string) {
|
|||
log.Warn("clusterReady() is unstable for", shell.FormatDuration(last))
|
||||
return false, "clusterReady() is unstable for " + shell.FormatDuration(last)
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
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"
|
||||
}
|
||||
if d.Starts > 2 {
|
||||
if d.Current.StartAttempts > 2 {
|
||||
// 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 true, ""
|
||||
}
|
||||
*/
|
||||
|
||||
// this must be bool in string because accumulated output is sometimes
|
||||
// written to STDOUT, sometimes to http
|
||||
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
|
||||
var msg string
|
||||
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 data:", msg)
|
||||
|
||||
result = "EVENT start droplet url: " + url + "\n"
|
||||
result := "EVENT start droplet url: " + url + "\n"
|
||||
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
|
||||
}
|
||||
|
||||
|
|
18
structs.go
18
structs.go
|
@ -20,15 +20,15 @@ func (b *virtigoT) Enable() {
|
|||
|
||||
// this app's variables
|
||||
type virtigoT struct {
|
||||
cluster *pb.Cluster // basic cluster settings
|
||||
hmap map[*pb.Hypervisor]*HyperT // map to the local struct
|
||||
names []string
|
||||
hypers []*HyperT
|
||||
killcount int
|
||||
unstable time.Time // the last time the cluster was incorrect
|
||||
changed bool
|
||||
hyperPollDelay time.Duration // how often to poll the hypervisors
|
||||
unstableTimeout time.Duration // how long a droplet can be unstable until it's declared dead
|
||||
cluster *pb.Cluster // basic cluster settings
|
||||
hmap map[*pb.Hypervisor]*HyperT // map to the local struct
|
||||
names []string
|
||||
hypers []*HyperT
|
||||
killcount int
|
||||
unstable time.Time // the last time the cluster was incorrect
|
||||
changed bool
|
||||
// hyperPollDelay time.Duration // how often to poll the hypervisors
|
||||
// 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
|
||||
missingDropletTimeout time.Duration // how long a droplet can be missing for
|
||||
}
|
||||
|
|
25
watchdog.go
25
watchdog.go
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||
|
@ -37,27 +36,3 @@ func (h *HyperT) sendDirs() {
|
|||
|
||||
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