diff options
| author | Jeff Carr <[email protected]> | 2024-10-31 05:02:20 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-31 05:02:20 -0500 | 
| commit | 748f9b4608ccc03f71f40bf961948816a662b1ba (patch) | |
| tree | e24f78109e3eb9a221e73125b9b54602b82df82b | |
| parent | 123f64f56c480c9b40eb88010fe91701c33de0af (diff) | |
compiles. maybe works on some stuff still
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | create.go | 10 | ||||
| -rw-r--r-- | event.go | 27 | ||||
| -rw-r--r-- | structs.go | 18 | ||||
| -rw-r--r-- | watchdog.go | 25 | 
4 files changed, 23 insertions, 57 deletions
@@ -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 { @@ -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  } @@ -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  } diff --git a/watchdog.go b/watchdog.go index 7a72a54..0849f65 100644 --- a/watchdog.go +++ b/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() -		} -	} -}  | 
