Skip to content

Commit

Permalink
Merge pull request #210 from whywaita/fix/deleting-block
Browse files Browse the repository at this point in the history
Set deadline timeout for blocking loop of delete
  • Loading branch information
whywaita authored Jul 11, 2024
2 parents 8761f15 + 5e78b45 commit 916397e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/runner/runner_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type Runner struct {
var (
// ConcurrencyDeleting is value of concurrency
ConcurrencyDeleting atomic.Int64
// DeletingTimeout is timeout of deleting runner
DeletingTimeout = 3 * time.Minute
)

func (m *Manager) do(ctx context.Context) error {
Expand Down Expand Up @@ -104,12 +106,15 @@ func (m *Manager) removeRunners(ctx context.Context, t datastore.Target) error {
ConcurrencyDeleting.Add(1)

eg.Go(func() error {
cctx, cancel := context.WithTimeout(ctx, DeletingTimeout)
defer cancel()

defer func() {
sem.Release(1)
ConcurrencyDeleting.Add(-1)
}()

if err := m.removeRunner(ctx, t, runner, ghRunners); err != nil {
if err := m.removeRunner(cctx, t, runner, ghRunners); err != nil {
logger.Logf(false, "failed to delete runner: %+v", err)
}
return nil
Expand Down

0 comments on commit 916397e

Please sign in to comment.