From 6e884e763748c229647ac793ca7d2cfd6d8672e5 Mon Sep 17 00:00:00 2001 From: Jean Schmidt <4520845+jeanschmidt@users.noreply.github.com> Date: Wed, 7 Aug 2024 21:32:58 +0200 Subject: [PATCH] Runner variants to be aware of the lf. and lf.c. prefixes, to facilitate migrations (#5541) --- .../src/scale-runners/gh-runners.test.ts | 64 ++++++++++++++++++- .../runners/src/scale-runners/gh-runners.ts | 11 +++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.test.ts b/terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.test.ts index 322428d13e..05647921fc 100644 --- a/terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.test.ts +++ b/terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.test.ts @@ -682,7 +682,25 @@ runner_types: largedisk: disk_size: 300 ami123: - ami: ami-123`; + ami: ami-123 + lf.linux.4xlarge: + instance_type: c5.2xlarge + os: linux + max_available: 1 + disk_size: 150 + is_ephemeral: false + variants: + ephemeral: + is_ephemeral: true + lf.c.linux.4xlarge: + instance_type: c5.2xlarge + os: linux + max_available: 1 + disk_size: 150 + is_ephemeral: false + variants: + ephemeral: + is_ephemeral: true`; const getRunnerTypeResponse = new Map([ [ @@ -741,6 +759,50 @@ runner_types: ami: 'ami-123', }, ], + [ + 'lf.linux.4xlarge', + { + runnerTypeName: 'lf.linux.4xlarge', + instance_type: 'c5.2xlarge', + os: 'linux', + max_available: 1, + disk_size: 150, + is_ephemeral: false, + }, + ], + [ + 'lf.ephemeral.linux.4xlarge', + { + runnerTypeName: 'lf.ephemeral.linux.4xlarge', + instance_type: 'c5.2xlarge', + os: 'linux', + max_available: 1, + disk_size: 150, + is_ephemeral: true, + }, + ], + [ + 'lf.c.linux.4xlarge', + { + runnerTypeName: 'lf.c.linux.4xlarge', + instance_type: 'c5.2xlarge', + os: 'linux', + max_available: 1, + disk_size: 150, + is_ephemeral: false, + }, + ], + [ + 'lf.c.ephemeral.linux.4xlarge', + { + runnerTypeName: 'lf.c.ephemeral.linux.4xlarge', + instance_type: 'c5.2xlarge', + os: 'linux', + max_available: 1, + disk_size: 150, + is_ephemeral: true, + }, + ], ]); it('gets the contents, twice', async () => { diff --git a/terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.ts b/terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.ts index 22cdf6d97b..f41235b6ab 100644 --- a/terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.ts +++ b/terraform-aws-github-runner/modules/runners/lambdas/runners/src/scale-runners/gh-runners.ts @@ -376,7 +376,16 @@ export async function getRunnerTypes( return; } - result.set(`${variant}.${key}`, { ...runnerType, ...variantType, runnerTypeName: `${variant}.${key}` }); + let variantRunnTypeName: string; + if (key.startsWith('lf.c.')) { + variantRunnTypeName = `lf.c.${variant}.${key.slice(5)}`; + } else if (key.startsWith('lf.')) { + variantRunnTypeName = `lf.${variant}.${key.slice(3)}`; + } else { + variantRunnTypeName = `${variant}.${key}`; + } + + result.set(variantRunnTypeName, { ...runnerType, ...variantType, runnerTypeName: variantRunnTypeName }); }); } });