Skip to content

Commit e72650a

Browse files
committed
Encapsulate module for pool, refactoring
1 parent 572e968 commit e72650a

File tree

17 files changed

+297
-191
lines changed

17 files changed

+297
-191
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This [Terraform](https://www.terraform.io/) module creates the required infrastr
2222
- [Option 2: App](#option-2-app)
2323
- [Install app](#install-app)
2424
- [Encryption](#encryption)
25-
- [Simple Pool](#simple-pool)
25+
- [Pool](#pool)
2626
- [Idle runners](#idle-runners)
2727
- [Ephemeral runners](#ephemeral-runners)
2828
- [Prebuilt Images](#prebuilt-images)
@@ -252,13 +252,21 @@ module "runners" {
252252
253253
```
254254

255-
### Simple Pool
255+
### Pool
256256

257-
The module basically supports two options for keeping a pool of runners. One is via a simple pool which only supports org-level runners, the second option is [keeping runners idle](#idle-runners).
257+
The module basically supports two options for keeping a pool of runners. One is via a pool which only supports org-level runners, the second option is [keeping runners idle](#idle-runners).
258258

259-
The simple pool is introduced in combination with the ephemeral runners and is primary meant to ensure if any event is unexpected dropped, and no runner was created the pool can pick up the job. The pool is maintained by a lambda. Each time the lambda is triggered a check is preformed if the number of idler runners managed by the module are meeting the expected pool size. If not, the pool will be adjusted. Keep in mind that the scale down function is still active and will terminate instances that are detected to long as idle.
259+
The pool is introduced in combination with the ephemeral runners and is primary meant to ensure if any event is unexpected dropped, and no runner was created the pool can pick up the job. The pool is maintained by a lambda. Each time the lambda is triggered a check is preformed if the number of idler runners managed by the module are meeting the expected pool size. If not, the pool will be adjusted. Keep in mind that the scale down function is still active and will terminate instances that are detected to long as idle.
260260

261-
The simple pool is NOT enabled by default can can be enabled by setting the the size of the pool greater then 0. The [ephemeral example](./examples/ephemeral/README.md) contains a configuration options (commented out).
261+
```hcl
262+
pool_runner_owner = "my-org" # Org to which the runners are added
263+
pool_config = [{
264+
size = 20 # size of the pool
265+
schedule_expression = "cron(* * * * ? *)" # cron expression to trigger the adjustment of the pool
266+
}]
267+
```
268+
269+
The pool is NOT enabled by default can can be enabled by setting the at least one object to the pool config list. The [ephemeral example](./examples/ephemeral/README.md) contains a configuration options (commented out).
262270

263271
### Idle runners
264272

@@ -422,6 +430,10 @@ In case the setup does not work as intended follow the trace of events:
422430
| <a name="input_logging_retention_in_days"></a> [logging\_retention\_in\_days](#input\_logging\_retention\_in\_days) | Specifies the number of days you want to retain log events for the lambda log group. Possible values are: 0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | `number` | `180` | no |
423431
| <a name="input_market_options"></a> [market\_options](#input\_market\_options) | DEPCRECATED: Replaced by `instance_target_capacity_type`. | `string` | `null` | no |
424432
| <a name="input_minimum_running_time_in_minutes"></a> [minimum\_running\_time\_in\_minutes](#input\_minimum\_running\_time\_in\_minutes) | The time an ec2 action runner should be running at minimum before terminated if not busy. | `number` | `null` | no |
433+
| <a name="input_pool_config"></a> [pool\_config](#input\_pool\_config) | The configuration for updating the pool. The `pool_size` to adjust to by the events triggered by the the `schedule_expression. For example you can configure a cron expression for week days to adjust the pool to 10 and another expression for the weekend to adjust the pool to 1.` | <pre>list(object({<br> schedule_expression = string<br> size = number<br> }))</pre> | `[]` | no |
434+
| <a name="input_pool_lambda_reserved_concurrent_executions"></a> [pool\_lambda\_reserved\_concurrent\_executions](#input\_pool\_lambda\_reserved\_concurrent\_executions) | Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. | `number` | `1` | no |
435+
| <a name="input_pool_lambda_timeout"></a> [pool\_lambda\_timeout](#input\_pool\_lambda\_timeout) | Time out for the pool lambda lambda in seconds. | `number` | `60` | no |
436+
| <a name="input_pool_runner_owner"></a> [pool\_runner\_owner](#input\_pool\_runner\_owner) | The pool wil deploy runners to an GitHub org, set this value to the org to which you want the runners deployed. Repo level is not supported. | `string` | `null` | no |
425437
| <a name="input_redrive_build_queue"></a> [redrive\_build\_queue](#input\_redrive\_build\_queue) | Set options to attach (optional) a dead letter queue to the build queue, the queue between the webhook and the scale up lambda. You have the following options. 1. Disable by setting, `enalbed' to false. 2. Enable by setting `enabled` to `true`, `maxReceiveCount` to a number of max retries.` | <pre>object({<br> enabled = bool<br> maxReceiveCount = number<br> })</pre> | <pre>{<br> "enabled": false,<br> "maxReceiveCount": null<br>}</pre> | no |
426438
| <a name="input_repository_white_list"></a> [repository\_white\_list](#input\_repository\_white\_list) | List of repositories allowed to use the github app | `list(string)` | `[]` | no |
427439
| <a name="input_role_path"></a> [role\_path](#input\_role\_path) | The path that will be added to role path for created roles, if not set the environment name will be used. | `string` | `null` | no |
@@ -452,10 +464,6 @@ In case the setup does not work as intended follow the trace of events:
452464
| <a name="input_runners_scale_up_lambda_timeout"></a> [runners\_scale\_up\_lambda\_timeout](#input\_runners\_scale\_up\_lambda\_timeout) | Time out for the scale up lambda in seconds. | `number` | `30` | no |
453465
| <a name="input_scale_down_schedule_expression"></a> [scale\_down\_schedule\_expression](#input\_scale\_down\_schedule\_expression) | Scheduler expression to check every x for scale down. | `string` | `"cron(*/5 * * * ? *)"` | no |
454466
| <a name="input_scale_up_reserved_concurrent_executions"></a> [scale\_up\_reserved\_concurrent\_executions](#input\_scale\_up\_reserved\_concurrent\_executions) | Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. | `number` | `1` | no |
455-
| <a name="input_simple_pool_config"></a> [simple\_pool\_config](#input\_simple\_pool\_config) | The configuration for updating the pool. The `pool_size` to adjust to by the events triggered by the the `schedule_expression. For example you can configure a cron expression for week days to adjust the pool to 10 and another expression for the weekend to adjust the pool to 1.` | <pre>list(object({<br> schedule_expression = string<br> pool_size = number<br> }))</pre> | `[]` | no |
456-
| <a name="input_simple_pool_lambda_timeout"></a> [simple\_pool\_lambda\_timeout](#input\_simple\_pool\_lambda\_timeout) | Time out for the simple pool lambda lambda in seconds. | `number` | `60` | no |
457-
| <a name="input_simple_pool_reserved_concurrent_executions"></a> [simple\_pool\_reserved\_concurrent\_executions](#input\_simple\_pool\_reserved\_concurrent\_executions) | Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. | `number` | `1` | no |
458-
| <a name="input_simple_pool_runner_owner"></a> [simple\_pool\_runner\_owner](#input\_simple\_pool\_runner\_owner) | The simple pool wil deploy runners to an GitHub org, set this value to the org to which you want the runners deployed. Repo level is not supported. | `string` | `null` | no |
459467
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | n/a | yes |
460468
| <a name="input_syncer_lambda_s3_key"></a> [syncer\_lambda\_s3\_key](#input\_syncer\_lambda\_s3\_key) | S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
461469
| <a name="input_syncer_lambda_s3_object_version"></a> [syncer\_lambda\_s3\_object\_version](#input\_syncer\_lambda\_s3\_object\_version) | S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |

examples/ephemeral/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ module "runners" {
5858
enable_ephemeral_runners = true
5959

6060
# # Example of simple pool usages
61-
# simple_pool_runner_owner = "my-org"
62-
# simple_pool_config = [{
63-
# pool_size = 2
64-
# schedule_expression = "cron(*/2 * * * ? *)"
61+
# pool_runner_owner = "my-org"
62+
# pool_config = [{
63+
# size = 20
64+
# schedule_expression = "cron(* * * * ? *)"
6565
# }]
6666

6767
# configure your pre-built AMI
6868
# enabled_userdata = false
69-
# ami_filter = { name = ["github-runner-amzn2-x86_64-2021*"] }
70-
# ami_owners = [data.aws_caller_identity.current.account_id]
69+
# ami_filter = { name = ["github-runner-amzn2-x86_64-2021*"] }
70+
# ami_owners = [data.aws_caller_identity.current.account_id]
7171

7272
# Enable logging
7373
log_level = "debug"

main.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,10 @@ module "runners" {
160160
log_type = var.log_type
161161
log_level = var.log_level
162162

163-
simple_pool_config = var.simple_pool_config
164-
simple_pool_lambda_timeout = var.simple_pool_lambda_timeout
165-
simple_pool_runner_owner = var.simple_pool_runner_owner
166-
simple_pool_reserved_concurrent_executions = var.simple_pool_reserved_concurrent_executions
167-
163+
pool_config = var.pool_config
164+
pool_lambda_timeout = var.pool_lambda_timeout
165+
pool_runner_owner = var.pool_runner_owner
166+
pool_lambda_reserved_concurrent_executions = var.pool_lambda_reserved_concurrent_executions
168167
}
169168

170169
module "runner_binaries" {

0 commit comments

Comments
 (0)