diff options
| author | Jeff Carr <[email protected]> | 2024-10-30 19:38:12 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-30 19:38:12 -0500 |
| commit | 41673f31706a4c68a26d580e42983380a0f15934 (patch) | |
| tree | c620c31ad8c6e76933aa18b0ba78e7fb2ece6afa /start.go | |
| parent | eacf3b8bef9801126c5693660acc2d03e3664025 (diff) | |
reject start and create early if grid unstable
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'start.go')
| -rw-r--r-- | start.go | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -14,11 +14,29 @@ import ( pb "go.wit.com/lib/protobuf/virtbuf" ) +func isClusterStable() (string, error) { + // how long has the cluster been stable? + // wait until it is stable. use this to throttle droplet starts + dur := time.Since(me.unstable) + good := fmt.Sprintln("trying to start droplet here. grid stable for: ", shell.FormatDuration(dur)) + if dur < me.unstableTimeout { + tmp := shell.FormatDuration(me.unstableTimeout) + err := "grid is still too unstable (unstable timeout = " + tmp + ")\n" + return good + err, errors.New(err) + } + return good, nil +} + // for now, because sometimes this should write to stdout and // sometimes to http socket, it returns a string func Start(name string) (string, error) { var result string + if s, err := isClusterStable(); err != nil { + result += s + return result, err + } + // lookup the droplet by name d := findDroplet(name) if d == nil { @@ -38,16 +56,6 @@ func Start(name string) (string, error) { return result, errors.New(result) } - // how long has the cluster been stable? - // wait until it is stable. use this to throttle droplet starts - dur := time.Since(me.unstable) - result = fmt.Sprintln("should start droplet", name, "here. grid stable for:", shell.FormatDuration(dur)) - if dur < me.unstableTimeout { - tmp := shell.FormatDuration(me.unstableTimeout) - result += "grid is still too unstable (unstable timeout = " + tmp + ")" - return result, errors.New("grid is still unstable") - } - // make the list of hypervisors that are active and can start new droplets var pool []*HyperT for _, h := range me.hypers { |
