Skip to content

Commit 7a6e99d

Browse files
authored
Merge pull request #1886 from philips-labs/develop
Release
2 parents f76a227 + defc198 commit 7a6e99d

File tree

14 files changed

+972
-950
lines changed

14 files changed

+972
-950
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ In case the setup does not work as intended follow the trace of events:
401401
| <a name="input_ami_owners"></a> [ami\_owners](#input\_ami\_owners) | The list of owners used to select the AMI of action runner instances. | `list(string)` | <pre>[<br> "amazon"<br>]</pre> | no |
402402
| <a name="input_aws_partition"></a> [aws\_partition](#input\_aws\_partition) | (optiona) partition in the arn namespace to use if not 'aws' | `string` | `"aws"` | no |
403403
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region. | `string` | n/a | yes |
404-
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops` | `map(string)` | `{}` | no |
404+
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops` | <pre>list(object({<br> device_name = string<br> delete_on_termination = bool<br> volume_type = string<br> volume_size = number<br> encrypted = bool<br> iops = number<br> }))</pre> | `[]` | no |
405405
| <a name="input_cloudwatch_config"></a> [cloudwatch\_config](#input\_cloudwatch\_config) | (optional) Replaces the module default cloudwatch log config. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html for details. | `string` | `null` | no |
406406
| <a name="input_create_service_linked_role_spot"></a> [create\_service\_linked\_role\_spot](#input\_create\_service\_linked\_role\_spot) | (optional) create the serviced linked role for spot instances that is required by the scale-up lambda. | `bool` | `false` | no |
407407
| <a name="input_delay_webhook_event"></a> [delay\_webhook\_event](#input\_delay\_webhook\_event) | The number of seconds the event accepted by the webhook is invisible on the queue before the scale up lambda will receive the event. | `number` | `30` | no |

examples/ubuntu/main.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,15 @@ module "runners" {
5656
# ami_owners = [data.aws_caller_identity.current.account_id]
5757

5858

59-
block_device_mappings = {
59+
block_device_mappings = [{
6060
# Set the block device name for Ubuntu root device
61-
device_name = "/dev/sda1"
62-
}
61+
device_name = "/dev/sda1"
62+
delete_on_termination = true
63+
volume_type = "gp3"
64+
volume_size = 30
65+
encrypted = true
66+
iops = null
67+
}]
6368

6469
runner_log_files = [
6570
{

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@
1818
"@octokit/rest": "^18.12.0",
1919
"@trivago/prettier-plugin-sort-imports": "^3.2.0",
2020
"@types/jest": "^27.4.1",
21-
"@types/node": "^17.0.21",
21+
"@types/node": "^17.0.23",
2222
"@types/request": "^2.48.8",
2323
"@typescript-eslint/eslint-plugin": "^4.33.0",
2424
"@typescript-eslint/parser": "^4.33.0",
2525
"@vercel/ncc": "^0.33.3",
26-
"aws-sdk": "^2.1094.0",
26+
"aws-sdk": "^2.1097.0",
2727
"eslint": "^7.32.0",
2828
"eslint-plugin-prettier": "4.0.0",
2929
"jest": "^27.5.1",
3030
"jest-mock": "^27.5.1",
31-
"prettier": "2.5.1",
31+
"prettier": "2.6.1",
3232
"ts-jest": "^27.1.3",
3333
"ts-node-dev": "^1.1.6",
3434
"typescript": "^4.6.2"
3535
},
3636
"dependencies": {
3737
"axios": "^0.26.1",
38-
"tslog": "^3.3.2"
38+
"tslog": "^3.3.3"
3939
}
4040
}

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/yarn.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -828,10 +828,10 @@
828828
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
829829
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
830830

831-
"@types/node@*", "@types/node@^17.0.21":
832-
version "17.0.21"
833-
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644"
834-
integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==
831+
"@types/node@*", "@types/node@^17.0.23":
832+
version "17.0.23"
833+
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.23.tgz#3b41a6e643589ac6442bdbd7a4a3ded62f33f7da"
834+
integrity sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==
835835

836836
"@types/prettier@^2.1.5":
837837
version "2.4.2"
@@ -1086,10 +1086,10 @@ asynckit@^0.4.0:
10861086
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
10871087
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
10881088

1089-
aws-sdk@^2.1094.0:
1090-
version "2.1094.0"
1091-
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1094.0.tgz#85cc5fb416ce7af356f1dd1b14fbb714cd923800"
1092-
integrity sha512-g/pjEl1JKs8+UZSdfdTMwUh7oNSWy6LXkjd0WfI3TBVgU5+yE5bd1VtAiJxJ/kIOFwcWyGPy0fNkGjAqL6NAGw==
1089+
aws-sdk@^2.1097.0:
1090+
version "2.1097.0"
1091+
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1097.0.tgz#1e53ee27d8ab7523760d023b934b24a9512bd719"
1092+
integrity sha512-fChMDiSfWcW0EUWmiqlyc+VAIXKH0w7BBruL3cVWSwO+5oA5A9juGF4NCBV2/KAHzaKaG0hXKPE49Wh6Lq74ag==
10931093
dependencies:
10941094
buffer "4.9.2"
10951095
events "1.1.1"
@@ -2975,10 +2975,10 @@ prettier-linter-helpers@^1.0.0:
29752975
dependencies:
29762976
fast-diff "^1.1.2"
29772977

2978-
prettier@2.5.1:
2979-
version "2.5.1"
2980-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
2981-
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==
2978+
prettier@2.6.1:
2979+
version "2.6.1"
2980+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.1.tgz#d472797e0d7461605c1609808e27b80c0f9cfe17"
2981+
integrity sha512-8UVbTBYGwN37Bs9LERmxCPjdvPxlEowx2urIL6urHzdb3SDq4B/Z6xLFCblrSnE4iKWcS6ziJ3aOYrc1kz/E2A==
29822982

29832983
pretty-format@^27.0.0, pretty-format@^27.5.1:
29842984
version "27.5.1"
@@ -3441,10 +3441,10 @@ tslib@^1.8.1:
34413441
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
34423442
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
34433443

3444-
tslog@^3.3.2:
3445-
version "3.3.2"
3446-
resolved "https://registry.yarnpkg.com/tslog/-/tslog-3.3.2.tgz#ceef419054a85d992cfdd923dc04aa0ea3539e24"
3447-
integrity sha512-K+XduMfa9+yiHE/vxbUD/dL7RAbw9yIfi9tMjQj3uQ8evkPRKkmw0mQgEkzmueyg23hJHGaOQmDnCEZoKEws+w==
3444+
tslog@^3.3.3:
3445+
version "3.3.3"
3446+
resolved "https://registry.yarnpkg.com/tslog/-/tslog-3.3.3.tgz#751a469e0d36841bd7e03676c27e53e7ffe9bc3d"
3447+
integrity sha512-lGrkndwpAohZ9ntQpT+xtUw5k9YFV1DjsksiWQlBSf82TTqsSAWBARPRD9juI730r8o3Awpkjp2aXy9k+6vr+g==
34483448
dependencies:
34493449
source-map-support "^0.5.21"
34503450

modules/runners/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ yarn run dist
117117
| <a name="input_ami_owners"></a> [ami\_owners](#input\_ami\_owners) | The list of owners used to select the AMI of action runner instances. | `list(string)` | <pre>[<br> "amazon"<br>]</pre> | no |
118118
| <a name="input_aws_partition"></a> [aws\_partition](#input\_aws\_partition) | (optional) partition for the base arn if not 'aws' | `string` | `"aws"` | no |
119119
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region. | `string` | n/a | yes |
120-
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops` | `map(string)` | `{}` | no |
120+
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops` | <pre>list(object({<br> device_name = string<br> delete_on_termination = bool<br> volume_type = string<br> volume_size = number<br> encrypted = bool<br> iops = number<br> }))</pre> | `[]` | no |
121121
| <a name="input_cloudwatch_config"></a> [cloudwatch\_config](#input\_cloudwatch\_config) | (optional) Replaces the module default cloudwatch log config. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html for details. | `string` | `null` | no |
122122
| <a name="input_create_service_linked_role_spot"></a> [create\_service\_linked\_role\_spot](#input\_create\_service\_linked\_role\_spot) | (optional) create the service linked role for spot instances that is required by the scale-up lambda. | `bool` | `false` | no |
123123
| <a name="input_disable_runner_autoupdate"></a> [disable\_runner\_autoupdate](#input\_disable\_runner\_autoupdate) | Disable the auto update of the github runner agent. Be-aware there is a grace period of 30 days, see also the [GitHub article](https://github.blog/changelog/2022-02-01-github-actions-self-hosted-runners-can-now-disable-automatic-updates/) | `bool` | `false` | no |

modules/runners/lambdas/runners/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@
3030
"jest-mock-extended": "^2.0.1",
3131
"moment-timezone": "^0.5.34",
3232
"nock": "^13.2.4",
33-
"prettier": "2.5.1",
33+
"prettier": "2.6.1",
3434
"ts-jest": "^27.1.3",
3535
"ts-node": "^10.7.0",
3636
"ts-node-dev": "^1.1.6"
3737
},
3838
"dependencies": {
39-
"@aws-sdk/client-ssm": "^3.54.0",
39+
"@aws-sdk/client-ssm": "^3.54.1",
4040
"@octokit/auth-app": "3.6.1",
4141
"@octokit/rest": "^18.12.0",
4242
"@octokit/types": "^6.34.0",
4343
"@types/aws-lambda": "^8.10.93",
4444
"@types/express": "^4.17.11",
45-
"@types/node": "^17.0.21",
46-
"aws-sdk": "^2.1090.0",
45+
"@types/node": "^17.0.23",
46+
"aws-sdk": "^2.1100.0",
4747
"cron-parser": "^4.2.1",
48-
"tslog": "^3.3.2",
48+
"tslog": "^3.3.3",
4949
"typescript": "^4.6.2"
5050
}
5151
}

modules/runners/lambdas/runners/src/scale-runners/scale-down.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,32 +143,51 @@ const DEFAULT_RUNNERS_ORIGINAL = [
143143
launchTime: moment(new Date()).toDate(),
144144
repo: `${TEST_DATA.repositoryOwner}/${TEST_DATA.repositoryName}`,
145145
},
146+
{
147+
instanceId: 'i-busy-112',
148+
launchTime: moment(new Date())
149+
.subtract(minimumRunningTimeInMinutes + 27, 'minutes')
150+
.toDate(),
151+
type: 'Org',
152+
owner: TEST_DATA.repositoryOwner,
153+
},
146154
];
147155

148156
const DEFAULT_REGISTERED_RUNNERS = [
149157
{
150158
id: 101,
151159
name: 'i-idle-101',
160+
busy: false,
152161
},
153162
{
154163
id: 102,
155164
name: 'i-idle-102',
165+
busy: false,
156166
},
157167
{
158168
id: 103,
159169
name: 'i-oldest-idle-103',
170+
busy: false,
160171
},
161172
{
162173
id: 104,
163174
name: 'i-oldest-idle-104',
175+
busy: false,
164176
},
165177
{
166178
id: 105,
167179
name: 'i-running-105',
180+
busy: false,
168181
},
169182
{
170183
id: 106,
171184
name: 'i-running-106',
185+
busy: false,
186+
},
187+
{
188+
id: 112,
189+
name: 'i-busy-112',
190+
busy: true,
172191
},
173192
];
174193

@@ -260,7 +279,8 @@ describe('scaleDown', () => {
260279
);
261280

262281
RUNNERS_ALL_REMOVED = DEFAULT_RUNNERS_ORG.filter(
263-
(r) => !r.instanceId.includes('running') && !r.instanceId.includes('registered'),
282+
(r) =>
283+
!r.instanceId.includes('running') && !r.instanceId.includes('registered') && !r.instanceId.includes('busy'),
264284
);
265285
DEFAULT_RUNNERS_ORPHANED = DEFAULT_RUNNERS_ORIGINAL.filter(
266286
(r) => r.instanceId.includes('orphan') && !r.instanceId.includes('not-registered'),

modules/runners/lambdas/runners/src/scale-runners/scale-down.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ async function removeRunner(ec2runner: RunnerInfo, ghRunnerId: number): Promise<
111111
logger.error(`Failed to de-register GitHub runner: ${result.status}`, LogFields.print());
112112
}
113113
} catch (e) {
114-
logger.info(
115-
`Runner '${ec2runner.instanceId}' cannot be de-registered, most likely the runner is active.`,
116-
LogFields.print(),
117-
);
114+
logger.error(`Runner '${ec2runner.instanceId}' cannot be de-registered. Error: ${e}`, LogFields.print());
118115
}
119116
}
120117

@@ -135,10 +132,10 @@ async function evaluateAndRemoveRunners(
135132
const ghRunners = await listGitHubRunners(ec2Runner);
136133
const ghRunner = ghRunners.find((runner) => runner.name === ec2Runner.instanceId);
137134
if (ghRunner) {
138-
if (runnerMinimumTimeExceeded(ec2Runner)) {
135+
if (!ghRunner.busy && runnerMinimumTimeExceeded(ec2Runner)) {
139136
if (idleCounter > 0) {
140137
idleCounter--;
141-
logger.info(`Runner '${ec2Runner.instanceId}' will kept idle.`, LogFields.print());
138+
logger.info(`Runner '${ec2Runner.instanceId}' will be kept idle.`, LogFields.print());
142139
} else {
143140
logger.info(`Runner '${ec2Runner.instanceId}' will be terminated.`, LogFields.print());
144141
await removeRunner(ec2Runner, ghRunner.id);

0 commit comments

Comments
 (0)