Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 7506e9d

Browse files
committed
feat!: Remove old scale down mechanism (< 0.19.0) (#2519)
Migration: Option 1, upgrade to 2.x could cause orphan instances which will not be terminated by the scale-down function, thoses instances needs to be removed manual. Option 2, upgrade first to a verions 1.x and keep this version running till all instances before the upgrade are terminated. Next upgrade to 2.x.
1 parent 4677619 commit 7506e9d

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

Diff for: modules/runners/lambdas/runners/src/scale-runners/scale-down.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ describe('scaleDown', () => {
444444

445445
expect(mockOctokit.apps.getRepoInstallation).toBeCalledTimes(2);
446446
expect(mockOctokit.apps.getOrgInstallation).toBeCalledTimes(1);
447-
expect(terminateRunner).toBeCalledTimes(8);
447+
expect(terminateRunner).toBeCalledTimes(7);
448448
for (const toTerminate of RUNNERS_ALL_REMOVED) {
449449
expect(terminateRunner).toHaveBeenCalledWith(toTerminate.instanceId);
450450
}
@@ -558,7 +558,7 @@ describe('scaleDown', () => {
558558

559559
expect(mockOctokit.apps.getRepoInstallation).toBeCalledTimes(2);
560560
expect(mockOctokit.apps.getOrgInstallation).toBeCalledTimes(1);
561-
expect(terminateRunner).toBeCalledTimes(8);
561+
expect(terminateRunner).toBeCalledTimes(7);
562562
for (const toTerminate of RUNNERS_ALL_REMOVED) {
563563
expect(terminateRunner).toHaveBeenCalledWith(toTerminate.instanceId);
564564
}

Diff for: modules/runners/lambdas/runners/src/scale-runners/scale-down.ts

+1-19
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,6 @@ async function listAndSortRunners(environment: string) {
220220
});
221221
}
222222

223-
/**
224-
* We are moving to a new strategy to find and remove runners, this function will ensure
225-
* during migration runners tagged in the old way are removed.
226-
*/
227-
function filterLegacyRunners(ec2runners: RunnerList[]): RunnerInfo[] {
228-
return ec2runners
229-
.filter((ec2Runner) => ec2Runner.repo || ec2Runner.org)
230-
.map((ec2Runner) => ({
231-
instanceId: ec2Runner.instanceId,
232-
launchTime: ec2Runner.launchTime,
233-
type: ec2Runner.org ? 'Org' : 'Repo',
234-
owner: ec2Runner.org ? (ec2Runner.org as string) : (ec2Runner.repo as string),
235-
}));
236-
}
237-
238223
function filterRunners(ec2runners: RunnerList[]): RunnerInfo[] {
239224
return ec2runners.filter((ec2Runner) => ec2Runner.type) as RunnerInfo[];
240225
}
@@ -256,12 +241,9 @@ export async function scaleDown(): Promise<void> {
256241
logger.debug(`No active runners found for environment: '${environment}'`, LogFields.print());
257242
return;
258243
}
259-
const legacyRunners = filterLegacyRunners(ec2Runners);
260-
logger.debug(JSON.stringify(legacyRunners), LogFields.print());
261-
const runners = filterRunners(ec2Runners);
262244

245+
const runners = filterRunners(ec2Runners);
263246
await evaluateAndRemoveRunners(runners, scaleDownConfigs);
264-
await evaluateAndRemoveRunners(legacyRunners, scaleDownConfigs);
265247

266248
const activeEc2RunnersCountAfter = (await listAndSortRunners(environment)).length;
267249
logger.info(

0 commit comments

Comments
 (0)