summaryrefslogtreecommitdiff
path: root/add.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-31 04:52:14 -0500
committerJeff Carr <[email protected]>2024-10-31 04:52:14 -0500
commit67cb013c830db0da9918a125e2e4373993445939 (patch)
tree5b7551808389da33bc303afea52266e1bfdf07a5 /add.go
parent96f29d6f3b696347dea1c22a0f3bda834a136d32 (diff)
add time duration to cluster
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'add.go')
-rw-r--r--add.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/add.go b/add.go
index 96f3fcb..b0d196f 100644
--- a/add.go
+++ b/add.go
@@ -2,8 +2,10 @@ package virtbuf
import (
"fmt"
+ "time"
"github.com/google/uuid"
+ "go.wit.com/log"
)
// can the json protobuf output use a string and have a type handler
@@ -129,6 +131,17 @@ func (epb *Events) AppendEvent(e *Event) {
epb.Events = append(epb.Events, e)
}
+func (c *Cluster) ClusterStable() (bool, string) {
+ last := time.Since(c.Unstable.AsTime())
+ if last > c.UnstableTimeout.AsDuration() {
+ // the cluster has not been stable for 133 seconds
+ log.Warn("clusterReady() is stable for ", FormatDuration(c.UnstableTimeout.AsDuration()), " secs")
+ return true, fmt.Sprintln("clusterReady() is stable ", FormatDuration(c.UnstableTimeout.AsDuration()), " secs")
+ }
+ log.Warn("clusterReady() is unstable for", FormatDuration(last))
+ return false, "clusterReady() is unstable for " + FormatDuration(last)
+}
+
// check the cluster and droplet to make sure it's ready to start
func (c *Cluster) DropletReady(d *Droplet) (bool, string) {
if c == nil {