summaryrefslogtreecommitdiff
path: root/start.go
diff options
context:
space:
mode:
Diffstat (limited to 'start.go')
-rw-r--r--start.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/start.go b/start.go
index 556c2d0..ae1be08 100644
--- a/start.go
+++ b/start.go
@@ -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 {