Skip to content

Commit 28c02ce

Browse files
Timo Kollerkayman-mk
Timo Koller
andauthoredJun 5, 2023
feat: add support for wait_for_services_timeout option (#861)
## Description This PR adds the `wait_for_services_timeout` docker setting for the executor (see https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-section). I've found #513 while looking for a solution to our problem. After migrating from the Kubernetes executer to the docker-machine executer, we have had a couple of Gitlab jobs that are always waiting 30s before actually running the defined steps. I am aware of #819 but I believe this might be a quick win. ## Migrations required NO ## Test the change In order to test my change, I recommend to set ```hcl debug = { "output_runner_config_to_file": true, "output_runner_user_data_to_file": false } ``` and then run `terraform plan`. It will print the locally rendered `config.toml` that now contains the new setting: ``` [...] pre_clone_script = "" request_concurrency = 1 output_limit = 4096 limit = 0 wait_for_services_timeout = 30 [...] ``` --------- Co-authored-by: Matthias Kay <[email protected]>
1 parent 1eb9e71 commit 28c02ce

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed
 

Diff for: ‎README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
- [Resources](#resources) <!-- markdown-link-check-disable-line -->
1818
- [Inputs](#inputs) <!-- markdown-link-check-disable-line -->
1919
- [Outputs](#outputs) <!-- markdown-link-check-disable-line -->
20-
20+
-
2121
## The module
2222

2323
This [Terraform](https://www.terraform.io/) modules creates a [GitLab CI runner](https://docs.gitlab.com/runner/). A blog post
@@ -37,7 +37,7 @@ The original setup of the module is based on the blog post: [Auto scale GitLab C
3737
> We know that this is a breaking change causing some pain, but we think it is worth it. We hope you agree. And to make the
3838
> transition as smooth as possible, we have added a migration script to the `migrations` folder. It will cover almost all cases,
3939
> but some minor rework might still be possible.
40-
>
40+
>
4141
> Checkout [issue 819](https://github.com/cattle-ops/terraform-aws-gitlab-runner/issues/819)
4242
4343
The runners created by the module use spot instances by default for running the builds using the `docker+machine` executor.
@@ -693,6 +693,7 @@ Made with [contributors-img](https://contrib.rocks).
693693
| <a name="input_runners_shm_size"></a> [runners\_shm\_size](#input\_runners\_shm\_size) | shm\_size for the runners, will be used in the runner config.toml | `number` | `0` | no |
694694
| <a name="input_runners_token"></a> [runners\_token](#input\_runners\_token) | Token for the runner, will be used in the runner config.toml. | `string` | `"__REPLACED_BY_USER_DATA__"` | no |
695695
| <a name="input_runners_use_private_address"></a> [runners\_use\_private\_address](#input\_runners\_use\_private\_address) | Restrict runners to the use of a private IP address. If `runner_agent_uses_private_address` is set to `true`(default), `runners_use_private_address` will also apply for the agent. | `bool` | `true` | no |
696+
| <a name="input_runners_wait_for_services_timeout"></a> [runners\_wait\_for\_services\_timeout](#input\_runners\_wait\_for\_services\_timeout) | How long to wait for Docker services. Set to `-1` to disable. Default is `30`. | `number` | `30` | no |
696697
| <a name="input_runners_userdata"></a> [runners\_userdata](#input\_runners\_userdata) | Cloud-init user data that will be passed to the runner ec2 instance. Available only for `docker+machine` driver. Should not be base64 encrypted. | `string` | `""` | no |
697698
| <a name="input_runners_volume_type"></a> [runners\_volume\_type](#input\_runners\_volume\_type) | Runner instance volume type | `string` | `"gp2"` | no |
698699
| <a name="input_runners_volumes_tmpfs"></a> [runners\_volumes\_tmpfs](#input\_runners\_volumes\_tmpfs) | Mount a tmpfs in runner container. https://docs.gitlab.com/runner/executors/docker.html#mounting-a-directory-in-ram | <pre>list(object({<br> volume = string<br> options = string<br> }))</pre> | `[]` | no |

Diff for: ‎main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ locals {
133133
runners_pre_build_script = var.runners_pre_build_script
134134
runners_post_build_script = var.runners_post_build_script
135135
runners_pre_clone_script = var.runners_pre_clone_script
136+
runners_wait_for_services_timeout = var.runners_wait_for_services_timeout
136137
runners_request_concurrency = var.runners_request_concurrency
137138
runners_output_limit = var.runners_output_limit
138139
runners_check_interval = var.runners_check_interval

Diff for: ‎template/runner-config.tftpl

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ listen_address = "${prometheus_listen_address}"
2929
pull_policy = ${runners_pull_policies}
3030
runtime = "${runners_docker_runtime}"
3131
helper_image = "${runners_helper_image}"
32+
wait_for_services_timeout = "${runners_wait_for_services_timeout}"
3233
${runners_docker_services}
3334
[runners.docker.tmpfs]
3435
${runners_volumes_tmpfs}

Diff for: ‎variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,12 @@ variable "runners_output_limit" {
361361
default = 4096
362362
}
363363

364+
variable "runners_wait_for_services_timeout" {
365+
description = "How long to wait for Docker services. Set to -1 to disable. Default is 30."
366+
type = number
367+
default = 30
368+
}
369+
364370
variable "userdata_pre_install" {
365371
description = "User-data script snippet to insert before GitLab runner install"
366372
type = string

0 commit comments

Comments
 (0)
Please sign in to comment.