Skip to content

Commit

Permalink
feat: add update_interval and update_interval_when_expecting (#1173)
Browse files Browse the repository at this point in the history
## Description

It seems that the default values set by GitLab are not perfect. I often
saw rate limiting on the AWS API for autoscaling. Making these variables
configurable ensures to stay below the limits. These variable have the
same defaults as documented by GitLab:
https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersautoscaler-section

The best values depend on how many Runners you have deployed.

## Verification

None
  • Loading branch information
kayman-mk authored Aug 16, 2024
1 parent 8141bbc commit 6d04322
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ locals {
runners_capacity_per_instance = 1
runners_max_use_count = var.runner_worker_docker_autoscaler.max_use_count
runners_max_instances = var.runner_worker.max_jobs

runners_update_interval = var.runner_worker_docker_autoscaler.update_interval
runners_update_interval_when_expecting = var.runner_worker_docker_autoscaler.update_interval_when_expecting

runners_autoscaling = [for config in var.runner_worker_docker_autoscaler_autoscaling_options : {
for key, value in config :
# Convert key from snake_case to PascalCase which is the casing for this section.
Expand Down
3 changes: 3 additions & 0 deletions template/runner-docker-autoscaler-config.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
plugin = "fleeting-plugin-aws"

capacity_per_instance = ${runners_capacity_per_instance}
update_interval = ${runners_update_interval}
update_interval_when_expecting = ${runners_update_interval_when_expecting}

max_use_count = ${runners_max_use_count}
max_instances = ${runners_max_instances}

Expand Down
12 changes: 8 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -607,12 +607,16 @@ variable "runner_worker_docker_autoscaler" {
connector_config_user = User to connect to worker machine
key_pair_name = The name of the key pair used by the Runner to connect to the docker-machine Runner Workers. This variable is only supported when `enables` is set to `true`.
max_use_count = Max job number that can run on a worker
update_interval = The interval to check with the fleeting plugin for instance updates.
update_interval_when_expecting = The interval to check with the fleeting plugin for instance updates when expecting a state change.
EOT
type = object({
fleeting_plugin_version = optional(string, "1.0.0")
connector_config_user = optional(string, "ec2-user")
key_pair_name = optional(string, "runner-worker-key")
max_use_count = optional(number, 100)
fleeting_plugin_version = optional(string, "1.0.0")
connector_config_user = optional(string, "ec2-user")
key_pair_name = optional(string, "runner-worker-key")
max_use_count = optional(number, 100)
update_interval = optional(string, "1m")
update_interval_when_expecting = optional(string, "2s")
})
default = {}
}
Expand Down

0 comments on commit 6d04322

Please sign in to comment.