Skip to content

Commit 9a59774

Browse files
committed
feat(runners): refactor source type to use LambdaRunnerSource in runner configurations
1 parent 18309ae commit 9a59774

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lambdas/functions/control-plane/src/aws/runners.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DefaultTargetCapacityType, SpotAllocationStrategy } from '@aws-sdk/client-ec2';
2+
import { LambdaRunnerSource } from '../scale-runners/scale-up';
23

34
export type RunnerType = 'Org' | 'Repo';
45

@@ -42,7 +43,7 @@ export interface RunnerInputParameters {
4243
instanceAllocationStrategy: SpotAllocationStrategy;
4344
};
4445
numberOfRunners: number;
45-
source: 'scale-up-lambda' | 'pool-lambda';
46+
source: LambdaRunnerSource;
4647
amiIdSsmParameterName?: string;
4748
tracingEnabled?: boolean;
4849
onDemandFailoverOnError?: string[];

lambdas/functions/control-plane/src/aws/runners.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
2121
import ScaleError from './../scale-runners/ScaleError';
2222
import { createRunner, listEC2Runners, tag, terminateRunner, untag } from './runners';
2323
import type { RunnerInfo, RunnerInputParameters, RunnerType } from './runners.d';
24+
import { LambdaRunnerSource } from '../scale-runners/scale-up';
2425

2526
process.env.AWS_REGION = 'eu-east-1';
2627
const mockEC2Client = mockClient(EC2Client);
@@ -753,7 +754,7 @@ interface RunnerConfig {
753754
tracingEnabled?: boolean;
754755
onDemandFailoverOnError?: string[];
755756
scaleErrors: string[];
756-
source: 'scale-up-lambda' | 'pool-lambda';
757+
source: LambdaRunnerSource;
757758
}
758759

759760
function createRunnerConfig(runnerConfig: RunnerConfig): RunnerInputParameters {
@@ -786,7 +787,7 @@ interface ExpectedFleetRequestValues {
786787
totalTargetCapacity: number;
787788
imageId?: string;
788789
tracingEnabled?: boolean;
789-
source: 'scale-up-lambda' | 'pool-lambda';
790+
source: LambdaRunnerSource;
790791
}
791792

792793
function expectedCreateFleetRequest(expectedValues: ExpectedFleetRequestValues): CreateFleetCommandInput {

lambdas/functions/control-plane/src/scale-runners/scale-up.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { publishRetryMessage } from './job-retry';
1111

1212
const logger = createChildLogger('scale-up');
1313

14+
export type LambdaRunnerSource = 'scale-up-lambda' | 'pool-lambda';
15+
1416
export interface RunnerGroup {
1517
name: string;
1618
id: number;
@@ -248,7 +250,7 @@ export async function createRunners(
248250
ec2RunnerConfig: CreateEC2RunnerConfig,
249251
numberOfRunners: number,
250252
ghClient: Octokit,
251-
source: 'scale-up-lambda' | 'pool-lambda' = 'scale-up-lambda',
253+
source: LambdaRunnerSource = 'scale-up-lambda',
252254
): Promise<string[]> {
253255
const instances = await createRunner({
254256
runnerType: githubRunnerConfig.runnerType,
@@ -509,6 +511,7 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
509511
},
510512
newRunners,
511513
githubInstallationClient,
514+
'scale-up-lambda'
512515
);
513516

514517
// Not all runners we wanted were created, let's reject enough items so that

0 commit comments

Comments
 (0)