Skip to content

Commit

Permalink
improve culling
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Apr 23, 2024
1 parent b7098f5 commit 7ec0b81
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion PoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ private async Task StartPoolRunners(List<OrgConfiguration> orgConfig)

private async Task CullRunners(List<OrgConfiguration> orgConfig, List<Server> allHtzSrvs)
{
List<string> registeredServerNames = new List<string>();
foreach (OrgConfiguration org in orgConfig)
{
_logger.LogInformation($"Culling runners for {org.OrgName}...");
Expand Down Expand Up @@ -229,8 +230,25 @@ private async Task CullRunners(List<OrgConfiguration> orgConfig, List<Server> al
}
}
}


// Get remaining runners registered to github
githubRunners = await GitHubApi.GetRunners(org.GitHubToken, org.OrgName);
registeredServerNames.AddRange(githubRunners.runners.Select(x => x.name));
}

// Remove every VM that's not in the github registered runners
var remainingHtzServer = await _cc.GetAllServers();
foreach (var htzSrv in remainingHtzServer)
{
if (registeredServerNames.Contains(htzSrv.Name))
{
// If we know the server in github, skip
continue;
}
_logger.LogInformation($"Removing VM that is not in any GitHub registration: {htzSrv.Name}");
await _cc.DeleteRunner(htzSrv.Id);
}

}

private async Task<bool> DeleteRunner(DeleteRunnerTask rt)
Expand Down

0 comments on commit 7ec0b81

Please sign in to comment.