Include self correction on empty batch and avoid removing pending runners when cluster is busy (#3426)

This commit is contained in:
Nikola Jokic
2024-04-16 12:55:25 +02:00
committed by GitHub
parent 98854ef9c0
commit 963ae48a3f
5 changed files with 566 additions and 228 deletions

View File

@@ -164,6 +164,11 @@ func (l *Listener) Listen(ctx context.Context, handler Handler) error {
}
if msg == nil {
_, err := handler.HandleDesiredRunnerCount(ctx, 0, 0)
if err != nil {
return fmt.Errorf("handling nil message failed: %w", err)
}
continue
}

View File

@@ -177,12 +177,12 @@ func (w *Worker) HandleDesiredRunnerCount(ctx context.Context, count int, jobsCo
"jobsCompleted", jobsCompleted,
}
if w.lastPatch == targetRunnerCount && jobsCompleted == 0 {
w.logger.Info("Skipping patch", logValues...)
return targetRunnerCount, nil
if count == 0 && jobsCompleted == 0 {
w.lastPatchID = 0
} else {
w.lastPatchID++
}
w.lastPatchID++
w.lastPatch = targetRunnerCount
original, err := json.Marshal(