dump more code to virtigoxml

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-31 06:43:14 -05:00
parent e6ea90f8de
commit 4a58352ec2
1 changed files with 1 additions and 37 deletions

View File

@ -25,37 +25,10 @@ func (h *HyperT) RestartVirtigod() {
me.unstable = time.Now()
}
// checks if the cluster is ready and stable
func clusterReady() (bool, string) {
last := time.Since(me.unstable)
if last > me.unstableTimeout {
// the cluster has not been stable for 133 seconds
log.Warn("clusterReady() is stable for ", shell.FormatDuration(me.unstableTimeout), " secs")
return true, fmt.Sprintln("clusterReady() is stable ", shell.FormatDuration(me.unstableTimeout), " secs")
}
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.Current.State == pb.DropletState_ON {
return false, "EVENT start droplet is already ON"
}
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.Current.StartAttempts, " 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)
ready, result := me.cluster.DropletReady(d)
if !ready {
return false, result
}
@ -83,12 +56,3 @@ func (h *HyperT) start(d *pb.Droplet) (bool, string) {
return true, result
}
func findDropletByName(name string) *pb.Droplet {
for _, d := range me.cluster.Droplets {
if d.Hostname == name {
return d
}
}
return nil
}