Skip to content

Commit 63f4a29

Browse files
authored
Rewrite scaleDown to fix a series of bugs (#864)
On scaleDown: - [FIX] Guaranteed stop the runners from the oldest to the newest, avoiding having runners for too long; - [FIX] Fixed bug where a runner could be removed from GHA but kept running on AWS; - [IMPROVED] Try to maintain always a minimum of `minAvailableRunners` runners free;
1 parent 51d8113 commit 63f4a29

File tree

8 files changed

+1244
-341
lines changed

8 files changed

+1244
-341
lines changed

terraform-aws-github-runner/modules/runners/lambdas/runners/src/lambda.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { scaleDown as scaleDownL, scaleUp as scaleUpL } from './lambda';
33
import { Context, SQSEvent, ScheduledEvent } from 'aws-lambda';
44
import { mocked } from 'ts-jest/utils';
55
import nock from 'nock';
6-
import scaleDown from './scale-runners/scale-down';
6+
import { scaleDown } from './scale-runners/scale-down';
77
import { scaleUp } from './scale-runners/scale-up';
88

99
jest.mock('./scale-runners/scale-down');

terraform-aws-github-runner/modules/runners/lambdas/runners/src/lambda.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Context, SQSEvent, ScheduledEvent } from 'aws-lambda';
22

3-
import scaleDownR from './scale-runners/scale-down';
3+
import { scaleDown as scaleDownR } from './scale-runners/scale-down';
44
import { scaleUp as scaleUpR } from './scale-runners/scale-up';
55

66
// eslint-disable-next-line @typescript-eslint/no-explicit-any

terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export async function getRunnerTypes(
348348

349349
const config = YAML.parse(configYml);
350350
const result: Map<string, RunnerType> = new Map(
351-
/* eslint-disable @typescript-eslint/no-explicit-any */
351+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
352352
(Object.entries(config.runner_types) as [string, any][]).map(([prop, runner_type]) => [
353353
prop,
354354
{

terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/metrics.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@ export class ScaleDownMetrics extends Metrics {
578578
this.countEntry('run.count');
579579
}
580580

581+
/* istanbul ignore next */
582+
exception() {
583+
this.countEntry('run.exceptions_count');
584+
}
585+
581586
/* istanbul ignore next */
582587
runnerLessMinimumTime(ec2Runner: RunnerInfo) {
583588
this.countEntry(`run.ec2runners.notMinTime`);

0 commit comments

Comments
 (0)