diff --git a/controller/node.go b/controller/node.go index b7a1f815..19955233 100644 --- a/controller/node.go +++ b/controller/node.go @@ -58,19 +58,19 @@ func PostNode(c *gin.Context) { node.CA = in.CA node.Arch = "linux_amd64" + err = engine.Allocate(node) + if err != nil { + c.String(http.StatusBadRequest, err.Error()) + return + } + err = model.InsertNode(db, node) if err != nil { c.AbortWithStatus(http.StatusInternalServerError) return } - ok := engine.Allocate(node) - if !ok { - c.AbortWithStatus(http.StatusInternalServerError) - } else { - c.IndentedJSON(http.StatusOK, node) - } - + c.IndentedJSON(http.StatusOK, node) } func DeleteNode(c *gin.Context) { diff --git a/engine/engine.go b/engine/engine.go index 3923b4ac..ab1bee6c 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -26,7 +26,7 @@ type Engine interface { Cancel(int64, int64, *model.Node) error Stream(int64, int64, *model.Node) (io.ReadCloser, error) Deallocate(*model.Node) - Allocate(*model.Node) bool + Allocate(*model.Node) error Subscribe(chan *Event) Unsubscribe(chan *Event) } @@ -124,9 +124,23 @@ func (e *engine) Unsubscribe(c chan *Event) { e.bus.unsubscribe(c) } -func (e *engine) Allocate(node *model.Node) bool { - log.Infof("registered docker daemon %s", node.Addr) - return e.pool.allocate(node) +func (e *engine) Allocate(node *model.Node) error { + + // run the full build! + client, err := newDockerClient(node.Addr, node.Cert, node.Key, node.CA) + if err != nil { + log.Errorf("error creating docker client %s. %s.", node.Addr, err) + return err + } + version, err := client.Version() + if err != nil { + log.Errorf("error connecting to docker daemon %s. %s.", node.Addr, err) + return err + } + + log.Infof("registered docker daemon %s running version %s", node.Addr, version.Version) + e.pool.allocate(node) + return nil } func (e *engine) Deallocate(n *model.Node) { diff --git a/static/styles_gen/style.css b/static/styles_gen/style.css index 1d52d8a7..378bfc01 100644 --- a/static/styles_gen/style.css +++ b/static/styles_gen/style.css @@ -423,7 +423,7 @@ body.login div.alert { position: fixed; top: 0px; left: 0px; right: 0px; line-he .tt-open { position: absolute; top: 34px; left: 0px; z-index: 100; display: none; background: #FFF; min-width: 100%; border: 1px solid #eee; border-radius: 0px; } -.tt-selectable:hover, .tt-cursor { background: #f4f4f4; } +.tt-selectable:hover, .tt-cursor { background: #eff1f5; } .tt-selectable { padding: 1rem 0.75rem; cursor: pointer; display: flex; }