mirror of
https://github.com/docker/docs.git
synced 2026-03-27 14:28:47 +07:00
Do not show tasks from down nodes as active in ls
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> (cherry picked from commit 5d4401d6d72c647fa61501c40949b2d67c3f958b)
This commit is contained in:
@@ -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]++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user