mirror of https://github.com/docker/docs.git
fix issue with timeouts in mesos
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
2eb39be3ee
commit
10d232fe66
|
@ -514,7 +514,9 @@ func (c *Cluster) scheduleTask(t *task) bool {
|
||||||
if data != nil && json.Unmarshal(data, &inspect) == nil && len(inspect) == 1 {
|
if data != nil && json.Unmarshal(data, &inspect) == nil && len(inspect) == 1 {
|
||||||
container := &cluster.Container{Container: dockerclient.Container{Id: inspect[0].Id}, Engine: s.engine}
|
container := &cluster.Container{Container: dockerclient.Container{Id: inspect[0].Id}, Engine: s.engine}
|
||||||
if container, err := container.Refresh(); err == nil {
|
if container, err := container.Refresh(); err == nil {
|
||||||
|
if !t.done {
|
||||||
t.container <- container
|
t.container <- container
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,12 +529,16 @@ func (c *Cluster) scheduleTask(t *task) bool {
|
||||||
|
|
||||||
for _, container := range s.engine.Containers() {
|
for _, container := range s.engine.Containers() {
|
||||||
if container.Config.Labels[cluster.SwarmLabelNamespace+".mesos.task"] == taskID {
|
if container.Config.Labels[cluster.SwarmLabelNamespace+".mesos.task"] == taskID {
|
||||||
|
if !t.done {
|
||||||
t.container <- container
|
t.container <- container
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !t.done {
|
||||||
t.error <- fmt.Errorf("Container failed to create")
|
t.error <- fmt.Errorf("Container failed to create")
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import "sync"
|
||||||
type Item interface {
|
type Item interface {
|
||||||
ID() string
|
ID() string
|
||||||
Do() bool
|
Do() bool
|
||||||
|
Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queue is a simple item queue
|
// Queue is a simple item queue
|
||||||
|
@ -51,6 +52,7 @@ func (q *Queue) Process() {
|
||||||
|
|
||||||
func (q *Queue) remove(items ...Item) {
|
func (q *Queue) remove(items ...Item) {
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
|
item.Stop()
|
||||||
delete(q.items, item.ID())
|
delete(q.items, item.ID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ func (i *item) ID() string {
|
||||||
return i.id
|
return i.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *item) Stop() {}
|
||||||
|
|
||||||
func (i *item) Do() bool {
|
func (i *item) Do() bool {
|
||||||
i.count = i.count - 1
|
i.count = i.count - 1
|
||||||
return i.count == 0
|
return i.count == 0
|
||||||
|
|
|
@ -24,6 +24,7 @@ type task struct {
|
||||||
config *cluster.ContainerConfig
|
config *cluster.ContainerConfig
|
||||||
error chan error
|
error chan error
|
||||||
container chan *cluster.Container
|
container chan *cluster.Container
|
||||||
|
done bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *task) ID() string {
|
func (t *task) ID() string {
|
||||||
|
@ -34,6 +35,10 @@ func (t *task) Do() bool {
|
||||||
return t.cluster.scheduleTask(t)
|
return t.cluster.scheduleTask(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *task) Stop() {
|
||||||
|
t.done = true
|
||||||
|
}
|
||||||
|
|
||||||
func (t *task) build(slaveID string, offers map[string]*mesosproto.Offer) {
|
func (t *task) build(slaveID string, offers map[string]*mesosproto.Offer) {
|
||||||
t.Command = &mesosproto.CommandInfo{Shell: proto.Bool(false)}
|
t.Command = &mesosproto.CommandInfo{Shell: proto.Bool(false)}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue