From b930fb1757c660150fcea9f34b3a330920fb1612 Mon Sep 17 00:00:00 2001 From: Bohdan Shulha Date: Sun, 20 Oct 2024 13:42:32 +0200 Subject: [PATCH] fix: ptah-sh/ptah-server#239 better tracking of failed tasks --- internal/app/ptah-agent/service_monitor.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/app/ptah-agent/service_monitor.go b/internal/app/ptah-agent/service_monitor.go index 076342c..4828e7a 100644 --- a/internal/app/ptah-agent/service_monitor.go +++ b/internal/app/ptah-agent/service_monitor.go @@ -89,14 +89,14 @@ func (e *taskExecutor) monitorDaemonServiceLaunch(ctx context.Context, service * return nil } - tasksInDesiredState := 0 + tasksRunning := 0 for _, t := range tasks { - if t.DesiredState == t.Status.State { - tasksInDesiredState++ + if t.Status.State == swarm.TaskStateRunning { + tasksRunning++ } } - if tasksInDesiredState == len(tasks) { + if tasksRunning == int(*service.Spec.Mode.Replicated.Replicas) { successfullChecks++ } else { successfullChecks = 0