Cannot specify docker configuration with the register command if using docker-autoscaler executor
Cannot specify docker configuration with the register command if using docker-autoscaler executor
Summary
Cannot specify docker configuration with the register command if using docker-autoscaler executor
Steps to reproduce
--template-config file like this
config.template.toml
[[runners]]
name = "__REDACTED__"
executor = "docker-autoscaler"
[runners.cache]
Type = "s3"
Path = "gitlab-runner/cache/"
Shared = true
MaxUploadedArchiveSize = 0
[runners.cache.s3]
BucketName = "__REDACTED__"
BucketLocation = "__REDACTED__"
# Docker Executor config
[runners.docker]
image = "busybox:latest"
# Autoscaler config
[runners.autoscaler]
plugin = "fleeting-plugin-aws"
capacity_per_instance = 1
max_use_count = 1
max_instances = 10
[runners.autoscaler.plugin_config]
name = "my-docker-asg"
[runners.autoscaler.connector_config]
username = "ec2-user"
[[runners.autoscaler.policy]]
idle_count = 5
idle_time = "20m0s"
Register the runner with the register command.
sudo gitlab-runner register \
--template-config 'config.template.toml' \
--non-interactive \
--url "$GITLAB_URL" \
--registration-token "$REGISTRATION_TOKEN" \
--tag-list "$TAG_LIST" \
--executor 'docker-autoscaler' \
--docker-image 'busybox:latest'
Actual behavior
There is no [runners.docker] configuration in the generated config.toml.
config.toml
concurrent = 1
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "__REDACTED__"
limit = 1
url = "__REDACTED__"
id = 1719
token = "__REDACTED__"
token_obtained_at = 2023-06-06T15:50:15Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker-autoscaler"
[runners.cache]
Type = "s3"
Path = "gitlab-runner/cache/"
Shared = true
MaxUploadedArchiveSize = 0
[runners.cache.s3]
BucketName = "__REDACTED__"
BucketLocation = "__REDACTED__"
[runners.autoscaler]
plugin = "fleeting-plugin-aws"
capacity_per_instance = 1
max_use_count = 1
max_instances = 10
[runners.autoscaler.plugin_config]
name = "my-docker-asg"
[runners.autoscaler.connector_config]
username = "ec2-user"
[[runners.autoscaler.policy]]
idle_count = 5
idle_time = "20m0s"
Expected behavior
The generated config.toml file must contain the [runners.docker] configuration read from the command line argument or template file.
Environment description
Used GitLab Runner version
Same happens with v15.11.1 and v16.0.1
Possible fixes
Adding handling for the "docker-autoscaler" executor to the gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).askExecutorOptions function seems to fix it.
func (s *RegisterCommand) askExecutorOptions() {
kubernetes := s.Kubernetes
machine := s.Machine
docker := s.Docker
ssh := s.SSH
parallels := s.Parallels
virtualbox := s.VirtualBox
custom := s.Custom
s.Kubernetes = nil
s.Machine = nil
s.Docker = nil
s.SSH = nil
s.Parallels = nil
s.VirtualBox = nil
s.Custom = nil
s.Referees = nil
executorFns := map[string]func(){
// ……
"docker-autoscaler": func() {
s.Docker = docker
s.askDocker()
},
// ……
}
executorFn, ok := executorFns[s.Executor]
if ok {
executorFn()
}
}
Edited by Bak, Jin Hyeong