Skip to content

Commit

Permalink
fix(scale-down): Clearing cache between runs (#1164)
Browse files Browse the repository at this point in the history
* fix(scale-down): Clearing cache between runs

* Removing debug statement
  • Loading branch information
mcaulifn authored Sep 14, 2021
1 parent ba2536b commit e72227b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/runners/lambdas/runners/src/scale-runners/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ export type GhRunners = UnboxPromise<ReturnType<Octokit['actions']['listSelfHost
export class githubCache {
static clients: Map<string, Octokit> = new Map();
static runners: Map<string, GhRunners> = new Map();

public static reset(): void {
githubCache.clients.clear();
githubCache.runners.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ async function listGitHubRunners(runner: RunnerInfo): Promise<GhRunners> {
runner.type === 'Org'
? await client.paginate(client.actions.listSelfHostedRunnersForOrg, {
org: runner.owner,
per_page: 100,
})
: await client.paginate(client.actions.listSelfHostedRunnersForRepo, {
owner: runner.owner.split('/')[0],
repo: runner.owner.split('/')[1],
per_page: 100,
});
githubCache.runners.set(key, runners);

Expand Down Expand Up @@ -182,6 +184,7 @@ function filterRunners(ec2runners: RunnerList[]): RunnerInfo[] {
}

export async function scaleDown(): Promise<void> {
githubCache.reset();
const scaleDownConfigs = JSON.parse(process.env.SCALE_DOWN_CONFIG) as [ScalingDownConfig];
const environment = process.env.ENVIRONMENT;

Expand Down

0 comments on commit e72227b

Please sign in to comment.