From bcc810146965e2d0516d34a8ef1af075dfb8107c Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Tue, 3 Oct 2023 14:55:17 +0200 Subject: [PATCH] feat: namespace EC2 tags --- .../control-plane/src/aws/runners.test.ts | 16 ++++++++-------- .../functions/control-plane/src/aws/runners.ts | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lambdas/functions/control-plane/src/aws/runners.test.ts b/lambdas/functions/control-plane/src/aws/runners.test.ts index ddb7098e54..ed044ff4fe 100644 --- a/lambdas/functions/control-plane/src/aws/runners.test.ts +++ b/lambdas/functions/control-plane/src/aws/runners.test.ts @@ -41,8 +41,8 @@ const mockRunningInstances: DescribeInstancesResult = { { Key: 'ghr:Application', Value: 'github-action-runner' }, { Key: 'ghr:runner_name_prefix', Value: RUNNER_NAME_PREFIX }, { Key: 'ghr:created_by', Value: 'scale-up-lambda' }, - { Key: 'Type', Value: 'Org' }, - { Key: 'Owner', Value: 'CoderToCat' }, + { Key: 'ghr:Type', Value: 'Org' }, + { Key: 'ghr:Owner', Value: 'CoderToCat' }, ], }, ], @@ -80,8 +80,8 @@ describe('list instances', () => { expect(mockEC2Client).toHaveReceivedCommandWith(DescribeInstancesCommand, { Filters: [ { Name: 'instance-state-name', Values: ['running', 'pending'] }, - { Name: 'tag:Type', Values: ['Repo'] }, - { Name: 'tag:Owner', Values: [REPO_NAME] }, + { Name: 'tag:ghr:Type', Values: ['Repo'] }, + { Name: 'tag:ghr:Owner', Values: [REPO_NAME] }, { Name: 'tag:ghr:Application', Values: ['github-action-runner'] }, ], }); @@ -93,8 +93,8 @@ describe('list instances', () => { expect(mockEC2Client).toHaveReceivedCommandWith(DescribeInstancesCommand, { Filters: [ { Name: 'instance-state-name', Values: ['running', 'pending'] }, - { Name: 'tag:Type', Values: ['Org'] }, - { Name: 'tag:Owner', Values: [ORG_NAME] }, + { Name: 'tag:ghr:Type', Values: ['Org'] }, + { Name: 'tag:ghr:Owner', Values: [ORG_NAME] }, { Name: 'tag:ghr:Application', Values: ['github-action-runner'] }, ], }); @@ -382,8 +382,8 @@ function expectedCreateFleetRequest(expectedValues: ExpectedFleetRequestValues): const tags = [ { Key: 'ghr:Application', Value: 'github-action-runner' }, { Key: 'ghr:created_by', Value: expectedValues.totalTargetCapacity > 1 ? 'pool-lambda' : 'scale-up-lambda' }, - { Key: 'Type', Value: expectedValues.type }, - { Key: 'Owner', Value: REPO_NAME }, + { Key: 'ghr:Type', Value: expectedValues.type }, + { Key: 'ghr:Owner', Value: REPO_NAME }, ]; const request: CreateFleetCommandInput = { LaunchTemplateConfigs: [ diff --git a/lambdas/functions/control-plane/src/aws/runners.ts b/lambdas/functions/control-plane/src/aws/runners.ts index b65885fc3d..a7e1b3af16 100644 --- a/lambdas/functions/control-plane/src/aws/runners.ts +++ b/lambdas/functions/control-plane/src/aws/runners.ts @@ -41,8 +41,8 @@ function constructFilters(filters?: Runners.ListRunnerFilters): Ec2Filter[][] { ec2FiltersBase.push({ Name: 'tag:ghr:environment', Values: [filters.environment] }); } if (filters.runnerType && filters.runnerOwner) { - ec2FiltersBase.push({ Name: `tag:Type`, Values: [filters.runnerType] }); - ec2FiltersBase.push({ Name: `tag:Owner`, Values: [filters.runnerOwner] }); + ec2FiltersBase.push({ Name: `tag:ghr:Type`, Values: [filters.runnerType] }); + ec2FiltersBase.push({ Name: `tag:ghr:Owner`, Values: [filters.runnerOwner] }); } } @@ -79,10 +79,10 @@ function getRunnerInfo(runningInstances: DescribeInstancesResult) { runners.push({ instanceId: i.InstanceId as string, launchTime: i.LaunchTime, - owner: i.Tags?.find((e) => e.Key === 'Owner')?.Value as string, - type: i.Tags?.find((e) => e.Key === 'Type')?.Value as string, - repo: i.Tags?.find((e) => e.Key === 'Repo')?.Value as string, - org: i.Tags?.find((e) => e.Key === 'Org')?.Value as string, + owner: i.Tags?.find((e) => e.Key === 'ghr:Owner')?.Value as string, + type: i.Tags?.find((e) => e.Key === 'ghr:Type')?.Value as string, + repo: i.Tags?.find((e) => e.Key === 'ghr:Repo')?.Value as string, + org: i.Tags?.find((e) => e.Key === 'ghr:Org')?.Value as string, }); } } @@ -147,8 +147,8 @@ export async function createRunner(runnerParameters: Runners.RunnerInputParamete const tags = [ { Key: 'ghr:Application', Value: 'github-action-runner' }, { Key: 'ghr:created_by', Value: numberOfRunners === 1 ? 'scale-up-lambda' : 'pool-lambda' }, - { Key: 'Type', Value: runnerParameters.runnerType }, - { Key: 'Owner', Value: runnerParameters.runnerOwner }, + { Key: 'ghr:Type', Value: runnerParameters.runnerType }, + { Key: 'ghr:Owner', Value: runnerParameters.runnerOwner }, ]; let fleet: CreateFleetResult;