Skip to content

Commit c028932

Browse files
Addressing npalm code review comments
1 parent 586d820 commit c028932

File tree

10 files changed

+28
-30
lines changed

10 files changed

+28
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ Talk to the forestkeepers in the `runners-channel` on Slack.
207207
| <a name="input_runner_binaries_syncer_lambda_zip"></a> [runner\_binaries\_syncer\_lambda\_zip](#input\_runner\_binaries\_syncer\_lambda\_zip) | File location of the binaries sync lambda zip file. | `string` | `null` | no |
208208
| <a name="input_runner_boot_time_in_minutes"></a> [runner\_boot\_time\_in\_minutes](#input\_runner\_boot\_time\_in\_minutes) | The minimum time for an EC2 runner to boot and register as a runner. | `number` | `5` | no |
209209
| <a name="input_runner_credit_specification"></a> [runner\_credit\_specification](#input\_runner\_credit\_specification) | The credit option for CPU usage of a T instance. Can be unset, "standard" or "unlimited". | `string` | `null` | no |
210+
| <a name="input_runner_disable_default_labels"></a> [runner\_disable\_default\_labels](#input\_runner\_disable\_default\_labels) | Disable default labels for the runners (os, architecture and `self-hosted`). If enabled, the runner will only have the extra labels provided in `runner_extra_labels`. | `bool` | `true` | no |
210211
| <a name="input_runner_ec2_tags"></a> [runner\_ec2\_tags](#input\_runner\_ec2\_tags) | Map of tags that will be added to the launch template instance tag specifications. | `map(string)` | `{}` | no |
211212
| <a name="input_runner_egress_rules"></a> [runner\_egress\_rules](#input\_runner\_egress\_rules) | List of egress rules for the GitHub runner instances. | <pre>list(object({<br/> cidr_blocks = list(string)<br/> ipv6_cidr_blocks = list(string)<br/> prefix_list_ids = list(string)<br/> from_port = number<br/> protocol = string<br/> security_groups = list(string)<br/> self = bool<br/> to_port = number<br/> description = string<br/> }))</pre> | <pre>[<br/> {<br/> "cidr_blocks": [<br/> "0.0.0.0/0"<br/> ],<br/> "description": null,<br/> "from_port": 0,<br/> "ipv6_cidr_blocks": [<br/> "::/0"<br/> ],<br/> "prefix_list_ids": null,<br/> "protocol": "-1",<br/> "security_groups": null,<br/> "self": null,<br/> "to_port": 0<br/> }<br/>]</pre> | no |
212-
| <a name="input_runner_enable_default_labels"></a> [runner\_enable\_default\_labels](#input\_runner\_enable\_default\_labels) | Enable default labels for the runners (os, architecture and `self-hosted`). If disabled, the runner will only have the extra labels provided in `runner_extra_labels`. In order set runner\_enable\_default\_labels = false, enable\_jit\_config and enable\_ephemeral\_runners must be set to true; otherwise the value of this variable will be considered as true | `bool` | `true` | no |
213213
| <a name="input_runner_extra_labels"></a> [runner\_extra\_labels](#input\_runner\_extra\_labels) | Extra (custom) labels for the runners (GitHub). Separate each label by a comma. Labels checks on the webhook can be enforced by setting `enable_workflow_job_labels_check`. GitHub read-only labels should not be provided. | `list(string)` | `[]` | no |
214214
| <a name="input_runner_group_name"></a> [runner\_group\_name](#input\_runner\_group\_name) | Name of the runner group. | `string` | `"Default"` | no |
215215
| <a name="input_runner_iam_role_managed_policy_arns"></a> [runner\_iam\_role\_managed\_policy\_arns](#input\_runner\_iam\_role\_managed\_policy\_arns) | Attach AWS or customer-managed IAM policies (by ARN) to the runner IAM role | `list(string)` | `[]` | no |

docs/configuration.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ The module uses the AWS System Manager Parameter Store to store configuration fo
2424
| `ssm_paths.root/var.prefix?/runners/config/<name>` | Configuration parameters used by runner start script |
2525
| `ssm_paths.root/var.prefix?/runners/tokens/<ec2-instance-id>` | Either JIT configuration (ephemeral runners) or registration tokens (non ephemeral runners) generated by the control plane (scale-up lambda), and consumed by the start script on the runner to activate / register the runner. |
2626
| `ssm_paths.root/var.prefix?/webhook/runner-matcher-config` | Runner matcher config used by webhook to decide the target for the webhook event. |
27+
2728
Available configuration parameters:
2829

29-
| Parameter name | Description |
30-
| ------------------- | ----------------------------------------------------------- |
31-
| `agent_mode` | Indicates if the agent is running in ephemeral mode or not. |
32-
| `enable_cloudwatch` | Configuration for the cloudwatch agent to stream logging. |
33-
| `run_as` | The user used for running the GitHub action runner agent. |
34-
| `token_path` | The path where tokens are stored. |
30+
| Parameter name | Description |
31+
|-------------------------------------|---------------------------------------------------------------------------------------------------|
32+
| `agent_mode` | Indicates if the agent is running in ephemeral mode or not. |
33+
| `disable_default_labels` | Indicates if the default labels for the runners (os, architecture and `self-hosted`) are disabled |
34+
| `enable_cloudwatch` | Configuration for the cloudwatch agent to stream logging. |
35+
| `run_as` | The user used for running the GitHub action runner agent. |
36+
| `token_path` | The path where tokens are stored. |
3537

3638
## Encryption
3739

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ locals {
99
}
1010

1111
default_runner_labels = distinct(concat(["self-hosted", var.runner_os, var.runner_architecture]))
12-
runner_labels = (var.runner_enable_default_labels == true) ? concat(local.default_runner_labels, var.runner_extra_labels) : var.runner_extra_labels
12+
runner_labels = (var.runner_disable_default_labels == false) ? concat(local.default_runner_labels, var.runner_extra_labels) : var.runner_extra_labels
1313

1414
ssm_root_path = var.ssm_paths.use_prefix ? "/${var.ssm_paths.root}/${var.prefix}" : "/${var.ssm_paths.root}"
1515
}
@@ -200,7 +200,7 @@ module "runners" {
200200
scale_down_schedule_expression = var.scale_down_schedule_expression
201201
minimum_running_time_in_minutes = var.minimum_running_time_in_minutes
202202
runner_boot_time_in_minutes = var.runner_boot_time_in_minutes
203-
runner_enable_default_labels = var.runner_enable_default_labels
203+
runner_disable_default_labels = var.runner_disable_default_labels
204204
runner_labels = local.runner_labels
205205
runner_as_root = var.runner_as_root
206206
runner_run_as = var.runner_run_as

modules/multi-runner/README.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

modules/multi-runner/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ variable "multi_runner_config" {
6161
pool_runner_owner = optional(string, null)
6262
runner_as_root = optional(bool, false)
6363
runner_boot_time_in_minutes = optional(number, 5)
64+
runner_disable_default_labels = optional(bool, false)
6465
runner_extra_labels = optional(list(string), [])
6566
runner_group_name = optional(string, "Default")
6667
runner_name_prefix = optional(string, "")
@@ -164,6 +165,7 @@ variable "multi_runner_config" {
164165
runner_additional_security_group_ids: "List of additional security groups IDs to apply to the runner. If added outside the multi_runner_config block, the additional security group(s) will be applied to all runner configs. If added inside the multi_runner_config, the additional security group(s) will be applied to the individual runner."
165166
runner_as_root: "Run the action runner under the root user. Variable `runner_run_as` will be ignored."
166167
runner_boot_time_in_minutes: "The minimum time for an EC2 runner to boot and register as a runner."
168+
runner_disable_default_labels: "Disable default labels for the runners (os, architecture and `self-hosted`). If enabled, the runner will only have the extra labels provided in `runner_extra_labels`."
167169
runner_extra_labels: "Extra (custom) labels for the runners (GitHub). Separate each label by a comma. Labels checks on the webhook can be enforced by setting `multi_runner_config.matcherConfig.exactMatch`. GitHub read-only labels should not be provided."
168170
runner_group_name: "Name of the runner group."
169171
runner_name_prefix: "Prefix for the GitHub runner name."

modules/runners/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ yarn run dist
117117
| [aws_launch_template.runner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource |
118118
| [aws_security_group.runner_sg](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
119119
| [aws_ssm_parameter.cloudwatch_agent_config_runner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
120-
| [aws_ssm_parameter.default_labels](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
120+
| [aws_ssm_parameter.disable_default_labels](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
121121
| [aws_ssm_parameter.jit_config_enabled](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
122122
| [aws_ssm_parameter.runner_agent_mode](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
123123
| [aws_ssm_parameter.runner_config_run_as](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
@@ -200,8 +200,8 @@ yarn run dist
200200
| <a name="input_runner_architecture"></a> [runner\_architecture](#input\_runner\_architecture) | The platform architecture of the runner instance\_type. | `string` | `"x64"` | no |
201201
| <a name="input_runner_as_root"></a> [runner\_as\_root](#input\_runner\_as\_root) | Run the action runner under the root user. Variable `runner_run_as` will be ignored. | `bool` | `false` | no |
202202
| <a name="input_runner_boot_time_in_minutes"></a> [runner\_boot\_time\_in\_minutes](#input\_runner\_boot\_time\_in\_minutes) | The minimum time for an EC2 runner to boot and register as a runner. | `number` | `5` | no |
203+
| <a name="input_runner_disable_default_labels"></a> [runner\_disable\_default\_labels](#input\_runner\_disable\_default\_labels) | Disable default labels for the runners (os, architecture and `self-hosted`). If enabled, the runner will only have the extra labels provided in `runner_extra_labels`. | `bool` | `false` | no |
203204
| <a name="input_runner_ec2_tags"></a> [runner\_ec2\_tags](#input\_runner\_ec2\_tags) | Map of tags that will be added to the launch template instance tag specifications. | `map(string)` | `{}` | no |
204-
| <a name="input_runner_enable_default_labels"></a> [runner\_enable\_default\_labels](#input\_runner\_enable\_default\_labels) | Enable default labels for the runners (os, architecture and `self-hosted`). If disabled, the runner will only have the extra labels provided in `runner_extra_labels`. | `bool` | `true` | no |
205205
| <a name="input_runner_group_name"></a> [runner\_group\_name](#input\_runner\_group\_name) | Name of the runner group. | `string` | `"Default"` | no |
206206
| <a name="input_runner_iam_role_managed_policy_arns"></a> [runner\_iam\_role\_managed\_policy\_arns](#input\_runner\_iam\_role\_managed\_policy\_arns) | Attach AWS or customer-managed IAM policies (by ARN) to the runner IAM role | `list(string)` | `[]` | no |
207207
| <a name="input_runner_labels"></a> [runner\_labels](#input\_runner\_labels) | All the labels for the runners (GitHub) including the default one's(e.g: self-hosted, linux, x64, label1, label2). Separate each label by a comma | `list(string)` | n/a | yes |

modules/runners/runner-config.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ resource "aws_ssm_parameter" "runner_agent_mode" {
1212
tags = local.tags
1313
}
1414

15-
resource "aws_ssm_parameter" "default_labels" {
16-
name = "${var.ssm_paths.root}/${var.ssm_paths.config}/default_labels"
15+
resource "aws_ssm_parameter" "disable_default_labels" {
16+
name = "${var.ssm_paths.root}/${var.ssm_paths.config}/disable_default_labels"
1717
type = "String"
18-
value = var.runner_enable_default_labels
18+
value = var.runner_disable_default_labels
1919
tags = local.tags
2020
}
2121

modules/runners/templates/start-runner.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ echo "Retrieved /$ssm_config_path/enable_cloudwatch parameter - ($enable_cloudwa
141141
agent_mode=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "'$ssm_config_path'/agent_mode") | .Value')
142142
echo "Retrieved /$ssm_config_path/agent_mode parameter - ($agent_mode)"
143143

144-
default_labels=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "'$ssm_config_path'/default_labels") | .Value')
145-
echo "Retrieved /$ssm_config_path/default_labels parameter - ($default_labels)"
144+
disable_default_labels=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "'$ssm_config_path'/disable_default_labels") | .Value')
145+
echo "Retrieved /$ssm_config_path/disable_default_labels parameter - ($disable_default_labels)"
146146

147147
enable_jit_config=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "'$ssm_config_path'/enable_jit_config") | .Value')
148148
echo "Retrieved /$ssm_config_path/enable_jit_config parameter - ($enable_jit_config)"
@@ -219,13 +219,12 @@ echo "Starting the runner as user $run_as"
219219
# configure the runner if the runner is non ephemeral or jit config is disabled
220220
if [[ "$enable_jit_config" == "false" || $agent_mode != "ephemeral" ]]; then
221221
echo "Configure GH Runner as user $run_as"
222-
if [[ "$default_labels" == "true" ]]; then
222+
if [[ "$disable_default_labels" == "true" ]]; then
223223
extra_flags="--no-default-labels"
224224
else
225225
extra_flags=""
226226
fi
227-
sudo --preserve-env=RUNNER_ALLOW_RUNASROOT -u "$run_as" -- ./config.sh ${extra_flags} --unattended --name "$runner_name_prefix$instance_id" --work "_work" $${config}
228-
227+
sudo --preserve-env=RUNNER_ALLOW_RUNASROOT -u "$run_as" -- ./config.sh $${extra_flags} --unattended --name "$runner_name_prefix$instance_id" --work "_work" $${config}
229228
fi
230229

231230
create_xray_success_segment "$SEGMENT"

modules/runners/variables.tf

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,15 @@ variable "runner_boot_time_in_minutes" {
217217
default = 5
218218
}
219219

220-
variable "runner_enable_default_labels" {
221-
description = "Enable default labels for the runners (os, architecture and `self-hosted`). If disabled, the runner will only have the extra labels provided in `runner_extra_labels`."
220+
variable "runner_disable_default_labels" {
221+
description = "Disable default labels for the runners (os, architecture and `self-hosted`). If enabled, the runner will only have the extra labels provided in `runner_extra_labels`."
222222
type = bool
223-
default = true
223+
default = false
224224
}
225225

226226
variable "runner_labels" {
227227
description = "All the labels for the runners (GitHub) including the default one's(e.g: self-hosted, linux, x64, label1, label2). Separate each label by a comma"
228228
type = list(string)
229-
230-
validation {
231-
condition = var.runner_labels != null && var.runner_labels != []
232-
error_message = "The runner_labels variable must be set."
233-
}
234229
}
235230

236231
variable "runner_group_name" {

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ variable "runner_boot_time_in_minutes" {
5858
default = 5
5959
}
6060

61-
variable "runner_enable_default_labels" {
62-
description = "Enable default labels for the runners (os, architecture and `self-hosted`). If disabled, the runner will only have the extra labels provided in `runner_extra_labels`. In order set runner_enable_default_labels = false, enable_jit_config and enable_ephemeral_runners must be set to true; otherwise the value of this variable will be considered as true"
61+
variable "runner_disable_default_labels" {
62+
description = "Disable default labels for the runners (os, architecture and `self-hosted`). If enabled, the runner will only have the extra labels provided in `runner_extra_labels`."
6363
type = bool
6464
default = true
6565
}

0 commit comments

Comments
 (0)