From e72227bd8c5d76f14c42119e17eae5762c247f85 Mon Sep 17 00:00:00 2001 From: Nathaniel McAuliffe Date: Tue, 14 Sep 2021 02:13:20 -0400 Subject: [PATCH] fix(scale-down): Clearing cache between runs (#1164) * fix(scale-down): Clearing cache between runs * Removing debug statement --- modules/runners/lambdas/runners/src/scale-runners/cache.ts | 5 +++++ .../runners/lambdas/runners/src/scale-runners/scale-down.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/modules/runners/lambdas/runners/src/scale-runners/cache.ts b/modules/runners/lambdas/runners/src/scale-runners/cache.ts index 8c0c34a14a..302a24b2d5 100644 --- a/modules/runners/lambdas/runners/src/scale-runners/cache.ts +++ b/modules/runners/lambdas/runners/src/scale-runners/cache.ts @@ -7,4 +7,9 @@ export type GhRunners = UnboxPromise = new Map(); static runners: Map = new Map(); + + public static reset(): void { + githubCache.clients.clear(); + githubCache.runners.clear(); + } } diff --git a/modules/runners/lambdas/runners/src/scale-runners/scale-down.ts b/modules/runners/lambdas/runners/src/scale-runners/scale-down.ts index f05c8317e0..f96df1893b 100644 --- a/modules/runners/lambdas/runners/src/scale-runners/scale-down.ts +++ b/modules/runners/lambdas/runners/src/scale-runners/scale-down.ts @@ -57,10 +57,12 @@ async function listGitHubRunners(runner: RunnerInfo): Promise { 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); @@ -182,6 +184,7 @@ function filterRunners(ec2runners: RunnerList[]): RunnerInfo[] { } export async function scaleDown(): Promise { + githubCache.reset(); const scaleDownConfigs = JSON.parse(process.env.SCALE_DOWN_CONFIG) as [ScalingDownConfig]; const environment = process.env.ENVIRONMENT;