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

Commit 116ea58

Browse files
authored
feat: tag runner volumes with the same tags as the instance (#3354)
* feat: tag runner volumes with the same tags as the instance * docs: update contribution guide * chore: git ignore terraform lock * chore: revert git ignore terraform lock
1 parent 22fad41 commit 116ea58

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ secrets.auto.tfvars
2222

2323
**/coverage/*
2424

25-
node_modules/
25+
node_modules/
26+

Diff for: CONTRIBUTING.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,36 @@ Before you submit your pull request consider the following guidelines:
6363

6464
* Create your patch, **including appropriate test cases**.
6565
* Install [Terraform](https://www.terraform.io/). We lock the version with [tfenv](https://github.com/tfutils/tfenv), check `required_version` in `versions.tf` for the current development version of the module.
66-
* Install [pre-commit hooks](https://pre-commit.com/). The hooks runs some basic checks. The commit will run the hooks, you can invoke the hooks manually `pre-commit run --all-files` as well.
66+
* Install [pre-commit hooks](https://pre-commit.com/). The hooks runs some basic checks. The commit will run the hooks, you can invoke the hooks manually `pre-commit run --all-files` as well. The hooks require tflint to be installed and terraform modules to be initialized.
67+
* Install [tflint](https://github.com/terraform-linters/tflint). We use tflint to lint the terraform code.
68+
* Initialize the terraform modules:
69+
70+
```shell
71+
terraform init
72+
```
73+
6774
* For updating docs, you have to enable GitHub actions on your forked repository. Simply go to the tab Actions and enable actions.
68-
* Commit your changes using a descriptive commit message.
75+
* Commit your changes using a descriptive commit message:
6976

7077
```shell
7178
git commit -a
7279
```
7380

7481
Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files.
7582

83+
* Install [node](https://nodejs.org/en/) and [yarn](https://yarnpkg.com/). We use yarn to lint, test and build the lambdas.
7684
* Build your changes locally to ensure all the tests pass:
85+
86+
```shell
87+
cd lambdas
88+
yarn install
89+
yarn format
90+
yarn lint
91+
yarn test
92+
yarn build
93+
cd ..
94+
```
95+
7796
* Push your branch to Github:
7897

7998
```shell

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

+12-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { GetParameterCommand, GetParameterResult, PutParameterCommand, SSMClient } from '@aws-sdk/client-ssm';
1313
import { mockClient } from 'aws-sdk-client-mock';
1414
import 'aws-sdk-client-mock-jest';
15+
import { performance } from 'perf_hooks';
1516

1617
import ScaleError from './../scale-runners/ScaleError';
1718
import { createRunner, listEC2Runners, terminateRunner } from './runners';
@@ -473,6 +474,12 @@ interface ExpectedFleetRequestValues {
473474
}
474475

475476
function expectedCreateFleetRequest(expectedValues: ExpectedFleetRequestValues): CreateFleetCommandInput {
477+
const tags = [
478+
{ Key: 'ghr:Application', Value: 'github-action-runner' },
479+
{ Key: 'ghr:created_by', Value: expectedValues.totalTargetCapacity > 1 ? 'pool-lambda' : 'scale-up-lambda' },
480+
{ Key: 'Type', Value: expectedValues.type },
481+
{ Key: 'Owner', Value: REPO_NAME },
482+
];
476483
const request: CreateFleetCommandInput = {
477484
LaunchTemplateConfigs: [
478485
{
@@ -507,12 +514,11 @@ function expectedCreateFleetRequest(expectedValues: ExpectedFleetRequestValues):
507514
TagSpecifications: [
508515
{
509516
ResourceType: 'instance',
510-
Tags: [
511-
{ Key: 'ghr:Application', Value: 'github-action-runner' },
512-
{ Key: 'ghr:created_by', Value: expectedValues.totalTargetCapacity > 1 ? 'pool-lambda' : 'scale-up-lambda' },
513-
{ Key: 'Type', Value: expectedValues.type },
514-
{ Key: 'Owner', Value: REPO_NAME },
515-
],
517+
Tags: tags,
518+
},
519+
{
520+
ResourceType: 'volume',
521+
Tags: tags,
516522
},
517523
],
518524
TargetCapacitySpecification: {

Diff for: lambdas/functions/control-plane/src/aws/runners.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ export async function createRunner(runnerParameters: Runners.RunnerInputParamete
157157
}
158158

159159
const numberOfRunners = runnerParameters.numberOfRunners ? runnerParameters.numberOfRunners : 1;
160+
const tags = [
161+
{ Key: 'ghr:Application', Value: 'github-action-runner' },
162+
{ Key: 'ghr:created_by', Value: numberOfRunners === 1 ? 'scale-up-lambda' : 'pool-lambda' },
163+
{ Key: 'Type', Value: runnerParameters.runnerType },
164+
{ Key: 'Owner', Value: runnerParameters.runnerOwner },
165+
];
160166

161167
let fleet: CreateFleetResult;
162168
try {
@@ -186,12 +192,11 @@ export async function createRunner(runnerParameters: Runners.RunnerInputParamete
186192
TagSpecifications: [
187193
{
188194
ResourceType: 'instance',
189-
Tags: [
190-
{ Key: 'ghr:Application', Value: 'github-action-runner' },
191-
{ Key: 'ghr:created_by', Value: numberOfRunners === 1 ? 'scale-up-lambda' : 'pool-lambda' },
192-
{ Key: 'Type', Value: runnerParameters.runnerType },
193-
{ Key: 'Owner', Value: runnerParameters.runnerOwner },
194-
],
195+
Tags: tags,
196+
},
197+
{
198+
ResourceType: 'volume',
199+
Tags: tags,
195200
},
196201
],
197202
Type: 'instant',

0 commit comments

Comments
 (0)