mirror of https://github.com/docker/docs.git
enable better refresh with mesos 0.23
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
a80cb7ba34
commit
58482a13d2
|
@ -17,7 +17,7 @@ type Container struct {
|
|||
}
|
||||
|
||||
// Refresh container
|
||||
func (c *Container) Refresh() error {
|
||||
func (c *Container) Refresh() (*Container, error) {
|
||||
return c.Engine.refreshContainer(c.Id, true)
|
||||
}
|
||||
|
||||
|
|
|
@ -227,15 +227,16 @@ func (e *Engine) RefreshContainers(full bool) error {
|
|||
|
||||
// Refresh the status of a container running on the engine. If `full` is true,
|
||||
// the container will be inspected.
|
||||
func (e *Engine) refreshContainer(ID string, full bool) error {
|
||||
func (e *Engine) refreshContainer(ID string, full bool) (*Container, error) {
|
||||
containers, err := e.client.ListContainers(true, false, fmt.Sprintf("{%q:[%q]}", "id", ID))
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(containers) > 1 {
|
||||
// We expect one container, if we get more than one, trigger a full refresh.
|
||||
return e.RefreshContainers(full)
|
||||
err = e.RefreshContainers(full)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(containers) == 0 {
|
||||
|
@ -244,11 +245,11 @@ func (e *Engine) refreshContainer(ID string, full bool) error {
|
|||
delete(e.containers, ID)
|
||||
e.Unlock()
|
||||
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
_, err = e.updateContainer(containers[0], e.containers, full)
|
||||
return err
|
||||
return e.containers[containers[0].Id], err
|
||||
}
|
||||
|
||||
func (e *Engine) updateContainer(c dockerclient.Container, containers map[string]*Container, full bool) (map[string]*Container, error) {
|
||||
|
@ -614,7 +615,8 @@ func (e *Engine) RenameContainer(container *Container, newName string) error {
|
|||
}
|
||||
|
||||
// refresh container
|
||||
return e.refreshContainer(container.Id, true)
|
||||
_, err = e.refreshContainer(container.Id, true)
|
||||
return err
|
||||
}
|
||||
|
||||
// BuildImage build an image
|
||||
|
|
|
@ -475,9 +475,9 @@ func (c *Cluster) scheduleTask(t *task) bool {
|
|||
// In mesos 0.23+ the docker inspect will be sent back in the taskStatus.Data
|
||||
// We can use this to find the right container.
|
||||
inspect := []dockerclient.ContainerInfo{}
|
||||
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}
|
||||
if container.Refresh() == nil {
|
||||
if container, err := container.Refresh(); err == nil {
|
||||
t.container <- container
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue