Browse code

Merge pull request #31311 from aaronlehmann/vendor-swarmkit-1f3e4e6

[17.03.x] Vendor swarmkit 1f3e4e6

Brian Goff authored on 2017/02/24 23:11:59
Showing 4 changed files
... ...
@@ -101,7 +101,7 @@ github.com/docker/containerd 977c511eda0925a723debdc94d09459af49d082a
101 101
 github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4
102 102
 
103 103
 # cluster
104
-github.com/docker/swarmkit 30a4278953316a0abd88d35c8d6600ff5add2733
104
+github.com/docker/swarmkit 1f3e4e67eeac60456460a270179711d0808129f9
105 105
 github.com/golang/mock bd3c8e81be01eef76d4b503f5e687d2d1354d2d9
106 106
 github.com/gogo/protobuf v0.3
107 107
 github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a
... ...
@@ -11,10 +11,10 @@ import (
11 11
 // NodeInfo contains a node and some additional metadata.
12 12
 type NodeInfo struct {
13 13
 	*api.Node
14
-	Tasks                             map[string]*api.Task
15
-	DesiredRunningTasksCount          int
16
-	DesiredRunningTasksCountByService map[string]int
17
-	AvailableResources                api.Resources
14
+	Tasks                     map[string]*api.Task
15
+	ActiveTasksCount          int
16
+	ActiveTasksCountByService map[string]int
17
+	AvailableResources        api.Resources
18 18
 
19 19
 	// recentFailures is a map from service ID to the timestamps of the
20 20
 	// most recent failures the node has experienced from replicas of that
... ...
@@ -28,9 +28,9 @@ func newNodeInfo(n *api.Node, tasks map[string]*api.Task, availableResources api
28 28
 	nodeInfo := NodeInfo{
29 29
 		Node:  n,
30 30
 		Tasks: make(map[string]*api.Task),
31
-		DesiredRunningTasksCountByService: make(map[string]int),
32
-		AvailableResources:                availableResources,
33
-		recentFailures:                    make(map[string][]time.Time),
31
+		ActiveTasksCountByService: make(map[string]int),
32
+		AvailableResources:        availableResources,
33
+		recentFailures:            make(map[string][]time.Time),
34 34
 	}
35 35
 
36 36
 	for _, t := range tasks {
... ...
@@ -48,9 +48,9 @@ func (nodeInfo *NodeInfo) removeTask(t *api.Task) bool {
48 48
 	}
49 49
 
50 50
 	delete(nodeInfo.Tasks, t.ID)
51
-	if oldTask.DesiredState == api.TaskStateRunning {
52
-		nodeInfo.DesiredRunningTasksCount--
53
-		nodeInfo.DesiredRunningTasksCountByService[t.ServiceID]--
51
+	if oldTask.DesiredState <= api.TaskStateRunning {
52
+		nodeInfo.ActiveTasksCount--
53
+		nodeInfo.ActiveTasksCountByService[t.ServiceID]--
54 54
 	}
55 55
 
56 56
 	reservations := taskReservations(t.Spec)
... ...
@@ -65,15 +65,15 @@ func (nodeInfo *NodeInfo) removeTask(t *api.Task) bool {
65 65
 func (nodeInfo *NodeInfo) addTask(t *api.Task) bool {
66 66
 	oldTask, ok := nodeInfo.Tasks[t.ID]
67 67
 	if ok {
68
-		if t.DesiredState == api.TaskStateRunning && oldTask.DesiredState != api.TaskStateRunning {
68
+		if t.DesiredState <= api.TaskStateRunning && oldTask.DesiredState > api.TaskStateRunning {
69 69
 			nodeInfo.Tasks[t.ID] = t
70
-			nodeInfo.DesiredRunningTasksCount++
71
-			nodeInfo.DesiredRunningTasksCountByService[t.ServiceID]++
70
+			nodeInfo.ActiveTasksCount++
71
+			nodeInfo.ActiveTasksCountByService[t.ServiceID]++
72 72
 			return true
73
-		} else if t.DesiredState != api.TaskStateRunning && oldTask.DesiredState == api.TaskStateRunning {
73
+		} else if t.DesiredState > api.TaskStateRunning && oldTask.DesiredState <= api.TaskStateRunning {
74 74
 			nodeInfo.Tasks[t.ID] = t
75
-			nodeInfo.DesiredRunningTasksCount--
76
-			nodeInfo.DesiredRunningTasksCountByService[t.ServiceID]--
75
+			nodeInfo.ActiveTasksCount--
76
+			nodeInfo.ActiveTasksCountByService[t.ServiceID]--
77 77
 			return true
78 78
 		}
79 79
 		return false
... ...
@@ -84,9 +84,9 @@ func (nodeInfo *NodeInfo) addTask(t *api.Task) bool {
84 84
 	nodeInfo.AvailableResources.MemoryBytes -= reservations.MemoryBytes
85 85
 	nodeInfo.AvailableResources.NanoCPUs -= reservations.NanoCPUs
86 86
 
87
-	if t.DesiredState == api.TaskStateRunning {
88
-		nodeInfo.DesiredRunningTasksCount++
89
-		nodeInfo.DesiredRunningTasksCountByService[t.ServiceID]++
87
+	if t.DesiredState <= api.TaskStateRunning {
88
+		nodeInfo.ActiveTasksCount++
89
+		nodeInfo.ActiveTasksCountByService[t.ServiceID]++
90 90
 	}
91 91
 
92 92
 	return true
... ...
@@ -33,8 +33,8 @@ func (ns *nodeSet) addOrUpdateNode(n NodeInfo) {
33 33
 	if n.Tasks == nil {
34 34
 		n.Tasks = make(map[string]*api.Task)
35 35
 	}
36
-	if n.DesiredRunningTasksCountByService == nil {
37
-		n.DesiredRunningTasksCountByService = make(map[string]int)
36
+	if n.ActiveTasksCountByService == nil {
37
+		n.ActiveTasksCountByService = make(map[string]int)
38 38
 	}
39 39
 	if n.recentFailures == nil {
40 40
 		n.recentFailures = make(map[string][]time.Time)
... ...
@@ -517,8 +517,8 @@ func (s *Scheduler) scheduleTaskGroup(ctx context.Context, taskGroup map[string]
517 517
 			}
518 518
 		}
519 519
 
520
-		tasksByServiceA := a.DesiredRunningTasksCountByService[t.ServiceID]
521
-		tasksByServiceB := b.DesiredRunningTasksCountByService[t.ServiceID]
520
+		tasksByServiceA := a.ActiveTasksCountByService[t.ServiceID]
521
+		tasksByServiceB := b.ActiveTasksCountByService[t.ServiceID]
522 522
 
523 523
 		if tasksByServiceA < tasksByServiceB {
524 524
 			return true
... ...
@@ -528,7 +528,7 @@ func (s *Scheduler) scheduleTaskGroup(ctx context.Context, taskGroup map[string]
528 528
 		}
529 529
 
530 530
 		// Total number of tasks breaks ties.
531
-		return a.DesiredRunningTasksCount < b.DesiredRunningTasksCount
531
+		return a.ActiveTasksCount < b.ActiveTasksCount
532 532
 	}
533 533
 
534 534
 	nodes := s.nodeSet.findBestNodes(len(taskGroup), s.pipeline.Process, nodeLess)