Skip to content

Commit ae6d38a

Browse files
feat: add MaxGrowthRate to limit the number of instances added in parallel (#962)
## Description This feature allows to support `MaxGrowthRate` which limits the number of instances added in parallel by the Runner. The default of `0` (unlimited) is used if no value is given. The parameter is added to `runner_worker_docker_machine_instance` as this is the only Runner type for which it makes sense. All other types are not able to scale and thus it is not a `runner_worker` parameter. See [advanced-configuration](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersmachine-section) Closes #851 ## Migrations required NO ## Verification - do not set the parameter --> `MaxGrowthRate` in config file is 0. - set the parameter to any value --> `MaxGrowthRate` in config file is "any value" --------- Co-authored-by: Matthias Kay <[email protected]> Co-authored-by: Matthias Kay <[email protected]>
1 parent 11ca10b commit ae6d38a

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

examples/runner-default/versions.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = "5.14.0"
7+
version = "5.15.0"
88
}
99
local = {
1010
source = "hashicorp/local"

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ locals {
107107
runners_spot_price_bid = var.runner_worker_docker_machine_instance_spot.max_price == "on-demand-price" || var.runner_worker_docker_machine_instance_spot.max_price == null ? "" : var.runner_worker_docker_machine_instance_spot.max_price
108108
runners_ami = var.runner_worker.type == "docker+machine" ? data.aws_ami.docker-machine[0].id : ""
109109
runners_security_group_name = var.runner_worker.type == "docker+machine" ? aws_security_group.docker_machine[0].name : ""
110+
runners_max_growth_rate = var.runner_worker_docker_machine_instance.max_growth_rate
110111
runners_monitoring = var.runner_worker_docker_machine_instance.monitoring
111112
runners_ebs_optimized = var.runner_worker_docker_machine_instance.ebs_optimized
112113
runners_instance_profile = var.runner_worker.type == "docker+machine" ? aws_iam_instance_profile.docker_machine[0].name : ""

template/runner-config.tftpl

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ listen_address = "${prometheus_listen_address}"
7575
%{~ endif ~}
7676
${docker_machine_options}
7777
]
78+
MaxGrowthRate = ${runners_max_growth_rate}
7879

7980
%{~ for config in runners_machine_autoscaling ~}
8081
[[runners.machine.autoscaling]]

variables.tf

+2
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ variable "runner_worker_docker_machine_instance" {
649649
ebs_optimized = Enable EBS optimization for the Runner Worker.
650650
idle_count = Number of idle Runner Worker instances (not working for the Docker Runner Worker) (IdleCount).
651651
idle_time = Idle time of the Runner Worker before they are destroyed (not working for the Docker Runner Worker) (IdleTime).
652+
max_growth_rate = The maximum number of machines that can be added to the runner in parallel.
652653
monitoring = Enable detailed monitoring for the Runner Worker.
653654
name_prefix = Set the name prefix and override the `Name` tag for the Runner Worker.
654655
private_address_only = Restrict Runner Worker to the use of a private IP address. If `runner_instance.use_private_address_only` is set to `true` (default), `runner_worker_docker_machine_instance.private_address_only` will also apply for the Runner.
@@ -664,6 +665,7 @@ variable "runner_worker_docker_machine_instance" {
664665
ebs_optimized = optional(bool, true)
665666
idle_count = optional(number, 0)
666667
idle_time = optional(number, 600)
668+
max_growth_rate = optional(number, 0)
667669
monitoring = optional(bool, false)
668670
name_prefix = optional(string, "")
669671
private_address_only = optional(bool, true)

0 commit comments

Comments
 (0)