Browse Source

Merge pull request #23875 from tonistiigi/task-node-down

Do not show tasks from down nodes as active in ls
Vincent Demeester 9 years ago
parent
commit
cf54dfba34
1 changed files with 12 additions and 1 deletions
  1. 12 1
      api/client/service/list.go

+ 12 - 1
api/client/service/list.go

@@ -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]++
 			}
 		}