diff options
| author | Jeff Carr <[email protected]> | 2024-10-31 04:52:14 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-31 04:52:14 -0500 |
| commit | 67cb013c830db0da9918a125e2e4373993445939 (patch) | |
| tree | 5b7551808389da33bc303afea52266e1bfdf07a5 /add.go | |
| parent | 96f29d6f3b696347dea1c22a0f3bda834a136d32 (diff) | |
add time duration to cluster
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'add.go')
| -rw-r--r-- | add.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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 { |
