mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Do not show tasks from down nodes as active in ls
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
138f9538f3
commit
5d4401d6d7
1 changed files with 12 additions and 1 deletions
|
@ -69,9 +69,20 @@ func runList(dockerCli *client.DockerCli, opts listOptions) error {
|
|||
return err
|
||||
}
|
||||
|
||||
nodes, err := client.NodeList(ctx, types.NodeListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
activeNodes := make(map[string]struct{})
|
||||
for _, n := range nodes {
|
||||
if n.Status.State == swarm.NodeStateReady {
|
||||
activeNodes[n.ID] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
running := map[string]int{}
|
||||
for _, task := range tasks {
|
||||
if task.Status.State == "running" {
|
||||
if _, nodeActive := activeNodes[task.NodeID]; nodeActive && task.Status.State == "running" {
|
||||
running[task.ServiceID]++
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue