Skip to content

Commit 3b775d2

Browse files
committed
fix: ptah-sh/ptah-server#239 better tracking of failed tasks
1 parent a525cc9 commit 3b775d2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

internal/app/ptah-agent/service_monitor.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ func (e *taskExecutor) monitorDaemonServiceLaunch(ctx context.Context, service *
5656
timeout := time.After(time.Duration(5) * time.Minute)
5757

5858
successfullChecks := 0
59+
lastFailedTasks := 0
60+
lastTasks := 0
5961

6062
for {
6163
select {
@@ -89,6 +91,12 @@ func (e *taskExecutor) monitorDaemonServiceLaunch(ctx context.Context, service *
8991
return nil
9092
}
9193

94+
if len(tasks) == lastTasks {
95+
continue
96+
}
97+
98+
lastTasks = len(tasks)
99+
92100
failedTasks := 0
93101
var lastErr string
94102
for _, t := range tasks {
@@ -98,13 +106,11 @@ func (e *taskExecutor) monitorDaemonServiceLaunch(ctx context.Context, service *
98106
}
99107
}
100108

101-
if failedTasks > 5 {
102-
return errors.Errorf("task failed: %s", lastErr)
103-
}
104-
105-
if failedTasks > 0 {
109+
if failedTasks > lastFailedTasks {
106110
log.Debug("service has failed tasks", "failed_tasks", failedTasks, "last_error", lastErr)
107111

112+
lastFailedTasks = failedTasks
113+
108114
continue
109115
}
110116

0 commit comments

Comments
 (0)