Skip to content

Commit 7df1032

Browse files
fix pool runner creation
1 parent 611e8c6 commit 7df1032

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

PoolManager.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
7676

7777
while (!stoppingToken.IsCancellationRequested)
7878
{
79-
80-
8179
if (DateTime.UtcNow - crudeStatsTimer > TimeSpan.FromSeconds(statsSeconds))
8280
{
8381
// Update config
@@ -474,11 +472,16 @@ private async Task StartPoolRunners(List<GithubTargetConfiguration> targetConfig
474472
continue;
475473
}
476474

477-
List<Runner> existingRunners = await db.Runners.Where(x => x.Owner == owner.Name && x.IsOnline).ToListAsync();
475+
List<Runner> activeRunners = await db.Runners
476+
.Include(x => x.Lifecycle)
477+
.Where(x => x.Owner == owner.Name)
478+
.ToListAsync();
479+
// Count runners that are still alive (not yet deleted/failed/cancelled)
480+
activeRunners = activeRunners.Where(x => x.LastState < RunnerStatus.DeletionQueued).ToList();
478481

479482
foreach (Pool pool in owner.Pools)
480483
{
481-
int existCt = existingRunners.Count(x => x.Size == pool.Size);
484+
int existCt = activeRunners.Count(x => x.Size == pool.Size);
482485
int missingCt = pool.NumRunners - existCt;
483486

484487
string arch = Program.Config.Sizes.FirstOrDefault(x => x.Name == pool.Size)?.Arch;

0 commit comments

Comments
 (0)