Unverified Commit d5bc8aa0 authored by Sune Keller's avatar Sune Keller 🐳

Only count tasks with version index greater than previous service index

Signed-off-by: Sune Keller's avatarSune Keller <absukl@almbrand.dk>
parent 58c8f31f
Pipeline #111088202 passed with stage
in 3 minutes and 32 seconds
......@@ -51,6 +51,7 @@ type statusContextType struct {
updating, completed map[string]struct{}
rolledBack, rollbackStarted map[string]string
failed map[string]failedStatus
servicesBefore map[string]*swarm.Service
serviceNames []string
}
......@@ -282,7 +283,7 @@ func main() {
mux := &sync.RWMutex{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
statusContext := statusContextType{ctx, mux, updating, completed, rolledBack, rollbackStarted, failed, serviceNames}
statusContext := statusContextType{ctx, mux, updating, completed, rolledBack, rollbackStarted, failed, servicesBefore, serviceNames}
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
check(statusContext)
......@@ -489,9 +490,14 @@ func check(ctx statusContextType) bool {
}
runningTasks := []swarm.Task{}
taskStates := map[swarm.TaskState]uint64{}
var serviceIndex uint64 = 0
serviceBefore, exists := ctx.servicesBefore[name]
if exists {
serviceIndex = serviceBefore.Version.Index
}
// Collect the number of tasks in each state desired to be running
for _, task := range tasks {
if task.DesiredState == swarm.TaskStateRunning {
if task.Version.Index > serviceIndex && task.DesiredState == swarm.TaskStateRunning {
state := task.Status.State
taskStates[state]++
runningTasks = append(runningTasks, task)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment