Skip to content

Commit 1fe25e3

Browse files
add stuck job info to creation queue
1 parent f8c8354 commit 1fe25e3

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

Models/CreateRunnerTask.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ public record CreateRunnerTask
1010
public string RepoName { get; set; }
1111
public int RunnerDbId { get; set; }
1212
public bool IsStuckReplacement { get; set; }
13+
public int? StuckJobId { get; set; }
1314
}

PoolManager.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,15 @@ private async Task CheckForStuckJobs(List<GithubTargetConfiguration> targetConfi
266266
_logger.LogError($"Unable to get owner for stuck job. {stuckJob.JobId}");
267267
continue;
268268
}
269+
270+
// Check if there is already a runner in queue to unstuck
271+
if (_queues.CreateTasks.Any(x => x.IsStuckReplacement && x.StuckJobId == stuckJob.JobId))
272+
{
273+
_logger.LogWarning($"Creating queue already has a task for jobs {stuckJob.JobId}");
274+
continue;
275+
}
276+
269277
int replacementsInQueue = _queues.CreateTasks.Count(x => x.IsStuckReplacement);
270-
271278
if (replacementsInQueue > 25)
272279
{
273280
_logger.LogWarning($"Creating queue already has {replacementsInQueue} stuck jobs replacements. No adding more strain");
@@ -308,14 +315,15 @@ private async Task CheckForStuckJobs(List<GithubTargetConfiguration> targetConfi
308315
await db.Runners.AddAsync(newRunner);
309316
await db.SaveChangesAsync();
310317

311-
_queues.CreateTasks.Enqueue(new CreateRunnerTask
312-
{
313-
RunnerToken = runnerToken,
314-
RepoName = stuckJob.Repository,
315-
TargetType = owner.Target,
316-
RunnerDbId = newRunner.RunnerId,
317-
IsStuckReplacement = true
318-
});
318+
_queues.CreateTasks.Enqueue(new CreateRunnerTask
319+
{
320+
RunnerToken = runnerToken,
321+
RepoName = stuckJob.Repository,
322+
TargetType = owner.Target,
323+
RunnerDbId = newRunner.RunnerId,
324+
IsStuckReplacement = true,
325+
StuckJobId = stuckJob.JobId
326+
});
319327
}
320328
}
321329

0 commit comments

Comments
 (0)