fix issue with timeouts in mesos

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux 2015-10-18 11:39:04 -07:00
parent 2eb39be3ee
commit 10d232fe66
4 changed files with 18 additions and 3 deletions

View File

@ -514,7 +514,9 @@ func (c *Cluster) scheduleTask(t *task) bool {
if data != nil && json.Unmarshal(data, &inspect) == nil && len(inspect) == 1 {
container := &cluster.Container{Container: dockerclient.Container{Id: inspect[0].Id}, Engine: s.engine}
if container, err := container.Refresh(); err == nil {
t.container <- container
if !t.done {
t.container <- container
}
return true
}
}
@ -527,12 +529,16 @@ func (c *Cluster) scheduleTask(t *task) bool {
for _, container := range s.engine.Containers() {
if container.Config.Labels[cluster.SwarmLabelNamespace+".mesos.task"] == taskID {
t.container <- container
if !t.done {
t.container <- container
}
return true
}
}
t.error <- fmt.Errorf("Container failed to create")
if !t.done {
t.error <- fmt.Errorf("Container failed to create")
}
return true
}

View File

@ -6,6 +6,7 @@ import "sync"
type Item interface {
ID() string
Do() bool
Stop()
}
// Queue is a simple item queue
@ -51,6 +52,7 @@ func (q *Queue) Process() {
func (q *Queue) remove(items ...Item) {
for _, item := range items {
item.Stop()
delete(q.items, item.ID())
}
}

View File

@ -15,6 +15,8 @@ func (i *item) ID() string {
return i.id
}
func (i *item) Stop() {}
func (i *item) Do() bool {
i.count = i.count - 1
return i.count == 0

View File

@ -24,6 +24,7 @@ type task struct {
config *cluster.ContainerConfig
error chan error
container chan *cluster.Container
done bool
}
func (t *task) ID() string {
@ -34,6 +35,10 @@ func (t *task) Do() bool {
return t.cluster.scheduleTask(t)
}
func (t *task) Stop() {
t.done = true
}
func (t *task) build(slaveID string, offers map[string]*mesosproto.Offer) {
t.Command = &mesosproto.CommandInfo{Shell: proto.Bool(false)}