Skip to content

Commit 3335b81

Browse files
authored
fix: autoscaler asg subnets and add possibility to enable metrics for asg (#1182)
## Description Add the possibility to have multiple subnets for runner manager instance with docker-autoscaler runner type. Add the variable `enabled_metrics` for docker autoscaler autoscaling group ## Migrations required No ## Verification Tested on our side on a production runner. To enable metrics for docker autoscaler autoscaling group you have to pass a list of metrics, here is my conf ``` runner_worker_docker_autoscaler_asg = { ... enabled_metrics = ["GroupMinSize", "GroupMaxSize", "GroupInServiceInstances", "GroupPendingInstances", "GroupStandbyInstances", "GroupTerminatingInstances", "GroupTotalInstances"] ```
1 parent 745fc46 commit 3335b81

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

docker_autoscaler.tf

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ resource "aws_autoscaling_group" "autoscaler" {
177177
health_check_grace_period = var.runner_worker_docker_autoscaler_asg.health_check_grace_period
178178
health_check_type = var.runner_worker_docker_autoscaler_asg.health_check_type
179179
force_delete = true
180+
enabled_metrics = var.runner_worker_docker_autoscaler_asg.enabled_metrics
180181

181182
dynamic "tag" {
182183
for_each = local.tags

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ locals {
183183
resource "aws_autoscaling_group" "gitlab_runner_instance" {
184184
# TODO Please explain how `agent_enable_asg_recreation` works
185185
name = var.runner_enable_asg_recreation ? "${aws_launch_template.gitlab_runner_instance.name}-asg" : "${var.environment}-as-group"
186-
vpc_zone_identifier = length(var.runner_worker_docker_machine_instance.subnet_ids) > 0 ? var.runner_worker_docker_machine_instance.subnet_ids : [var.subnet_id]
186+
vpc_zone_identifier = length(var.runner_worker_docker_machine_instance.subnet_ids) > 0 ? var.runner_worker_docker_machine_instance.subnet_ids : length(var.runner_worker_docker_autoscaler_asg.subnet_ids) > 0 ? var.runner_worker_docker_autoscaler_asg.subnet_ids : [var.subnet_id]
187187
min_size = "1"
188188
max_size = "1"
189189
desired_capacity = "1"

variables.tf

+2
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ variable "runner_worker_docker_autoscaler_asg" {
670670
subnet_ids = The list of subnet IDs to use for the Runner Worker when the fleet mode is enabled.
671671
types = The type of instance to use for the Runner Worker. In case of fleet mode, multiple instance types are supported.
672672
upgrade_strategy = Auto deploy new instances when launch template changes. Can be either 'bluegreen', 'rolling' or 'off'
673+
enabled_metrics = List of metrics to collect.
673674
EOT
674675
type = object({
675676
enable_mixed_instances_policy = optional(bool, false)
@@ -686,6 +687,7 @@ variable "runner_worker_docker_autoscaler_asg" {
686687
subnet_ids = optional(list(string), [])
687688
types = optional(list(string), ["m5.large"])
688689
upgrade_strategy = optional(string, "rolling")
690+
enabled_metrics = optional(list(string), [])
689691
sg_ingresses = optional(list(object({
690692
description = string
691693
from_port = number

0 commit comments

Comments
 (0)