Skip to content

Commit a6fccc1

Browse files
feat: add autoscaler runner instance ready command option (#1190)
## Description This adds the optional instance_ready_command parameter for the docker_autoscaler. This feature was added in Gitlab 16.11. See gitlab documentation for the [runners.autoscaler]: https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersautoscaler-section. Example value: `instance_ready_command = "cloud-init status --wait"` ## Migrations required No ## Verification Updated the runner_worker_docker_autoscaler by including the instance_ready_command ``` runner_worker_docker_autoscaler = { fleeting_plugin_version = "1.0.0" connector_config_user = "ec2-user" key_pair_name = "runner-worker-key" max_use_count = 100 update_interval = "1m" update_interval_when_expecting = "2s" capacity_per_instance = var.job_capacity_per_instance instance_ready_command = "\"cloud-init status --wait || test $? -eq 2\"" } ``` Confirmed this gets added correctly to the config.toml by enabling the var.debug_write_runner_config_to_file. Result on the local_file.config_toml[0]: ``` ... [runners.autoscaler] plugin = "fleeting-plugin-aws" capacity_per_instance = 1 update_interval = "1m" update_interval_when_expecting = "2s" max_use_count = 100 max_instances = 1 instance_ready_command = "cloud-init status --wait || test $? -eq 2" .... ``` If no value is given for the instance_ready_command the config.toml will default to ``` ... [runners.autoscaler] plugin = "fleeting-plugin-aws" capacity_per_instance = 1 update_interval = "1m" update_interval_when_expecting = "2s" max_use_count = 100 max_instances = 1 instance_ready_command="" ... ```
1 parent cd577fe commit a6fccc1

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

main.tf

+2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ locals {
131131
runners_update_interval = var.runner_worker_docker_autoscaler.update_interval
132132
runners_update_interval_when_expecting = var.runner_worker_docker_autoscaler.update_interval_when_expecting
133133

134+
runners_instance_ready_command = var.runner_worker_docker_autoscaler.instance_ready_command
135+
134136
runners_autoscaling = [for config in var.runner_worker_docker_autoscaler_autoscaling_options : {
135137
for key, value in config :
136138
# Convert key from snake_case to PascalCase which is the casing for this section.

template/runner-docker-autoscaler-config.tftpl

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
max_use_count = ${runners_max_use_count}
1010
max_instances = ${runners_max_instances}
1111

12+
instance_ready_command="${runners_instance_ready_command}"
13+
1214
[runners.autoscaler.plugin_config] # plugin specific configuration (see plugin documentation)
1315
name = "${docker_autoscaling_name}" # AWS Autoscaling Group name
1416

variables.tf

+2
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ variable "runner_worker_docker_autoscaler" {
610610
max_use_count = Max job number that can run on a worker
611611
update_interval = The interval to check with the fleeting plugin for instance updates.
612612
update_interval_when_expecting = The interval to check with the fleeting plugin for instance updates when expecting a state change.
613+
instance_ready_command = Executes this command on each instance provisioned by the autoscaler to ensure that it is ready for use. A failure results in the instance being removed.
613614
EOT
614615
type = object({
615616
fleeting_plugin_version = optional(string, "1.0.0")
@@ -619,6 +620,7 @@ variable "runner_worker_docker_autoscaler" {
619620
max_use_count = optional(number, 100)
620621
update_interval = optional(string, "1m")
621622
update_interval_when_expecting = optional(string, "2s")
623+
instance_ready_command = optional(string, "")
622624
})
623625
default = {}
624626
}

0 commit comments

Comments
 (0)