mirror of https://github.com/docker/docs.git
add build
improve random selection Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
parent
8506acbed2
commit
d74e872952
|
@ -15,7 +15,6 @@ Some endpoints have not yet been implemented and will return a 404 error.
|
|||
```
|
||||
GET "/images/get"
|
||||
|
||||
POST "/build"
|
||||
POST "/images/load"
|
||||
POST "/images/create" : "docker import" flow not implement
|
||||
```
|
||||
|
|
|
@ -395,7 +395,7 @@ func proxyImage(c *context, w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Proxy a request to a random node
|
||||
func proxyRandom(c *context, w http.ResponseWriter, r *http.Request) {
|
||||
engine, err := c.cluster.RandomEngine_()
|
||||
engine, err := c.cluster.RANDOMENGINE()
|
||||
if err != nil {
|
||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
|
|
@ -46,7 +46,7 @@ var routes = map[string]map[string]handler{
|
|||
"POST": {
|
||||
"/auth": proxyRandom,
|
||||
"/commit": postCommit,
|
||||
"/build": notImplementedHandler,
|
||||
"/build": proxyRandom,
|
||||
"/images/create": postImagesCreate,
|
||||
"/images/load": notImplementedHandler,
|
||||
"/images/{name:.*}/push": proxyImage,
|
||||
|
|
|
@ -42,5 +42,5 @@ type Cluster interface {
|
|||
|
||||
// FIXME: remove this method
|
||||
// Return a random engine
|
||||
RandomEngine_() (*Engine, error)
|
||||
RANDOMENGINE() (*Engine, error)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package swarm
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
|
@ -12,7 +11,6 @@ import (
|
|||
"github.com/docker/swarm/cluster"
|
||||
"github.com/docker/swarm/discovery"
|
||||
"github.com/docker/swarm/scheduler"
|
||||
"github.com/docker/swarm/scheduler/filter"
|
||||
"github.com/docker/swarm/scheduler/node"
|
||||
"github.com/docker/swarm/state"
|
||||
"github.com/samalba/dockerclient"
|
||||
|
@ -310,17 +308,14 @@ func (c *Cluster) Info() [][2]string {
|
|||
return info
|
||||
}
|
||||
|
||||
// RandomEngine_ returns a random engine.
|
||||
func (c *Cluster) RandomEngine_() (*cluster.Engine, error) {
|
||||
healthFilter := &filter.HealthFilter{}
|
||||
accepted, err := healthFilter.Filter(nil, c.listNodes())
|
||||
// RANDOMENGINE returns a random engine.
|
||||
func (c *Cluster) RANDOMENGINE() (*cluster.Engine, error) {
|
||||
n, err := c.scheduler.SelectNodeForContainer(c.listNodes(), &dockerclient.ContainerConfig{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if size := len(accepted); size > 0 {
|
||||
if n, ok := c.engines[accepted[rand.Intn(size)].ID]; ok {
|
||||
return n, nil
|
||||
}
|
||||
if n != nil {
|
||||
return c.engines[n.ID], nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue