Docker Machine failed to create EC2 spot instance: InvalidParameter: 'instance' is not a valid taggable resource type for this operation
Summary
After following the GitLab doc for setting up an autoscaling runner group, specifically after setting up the autoscaler EC2 instance (running Ubuntu 22.04 LTS), the gitlab-runner
service fails to create EC2 instances at the driver level because of an invalid parameter 'instance'
not being a valid taggable type.
Steps to reproduce
- Create a
t2.micro
EC2 instance running Ubuntu 22.04 LTS in AWS. - Install Docker Engine, the GitLab-maintained Docker Machine fork, and
gitlab-runner
. - Configure
gitlab-runner
according to the below config TOML. - Run
sudo gitlab-runner -l debug run
to obtain thedocker-machine
command enclosed in brackets, or simply observe the outputs. - (opt) Stop the previous command and run the
docker-machine
command by hand. - Observe the following failed behavior:
docker-machine output snip
Running pre-create checks...
Creating machine...
(runner-########-gitlab-docker-machine-##########-########) Launching instance...
(runner-########-gitlab-docker-machine-##########-########) Missing instance ID, this is likely due to a failure during machine creation
Error creating machine: Error in driver during machine creation: Error request spot instance: InvalidParameter: 'instance' is not a valid taggable resource type for this operation.
status code: 400, request id: <uuid>
Environment description
config.toml contents
concurrent = 12
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "<snip>"
url = "https://gitlab.com/"
token = "<snip>"
executor = "docker+machine"
limit = 10
[runners.custom_build_dir]
[runners.cache]
Type = "s3"
Shared = true
[runners.cache.s3]
ServerAddress = "s3.amazonaws.com"
AccessKey = "<snip>"
SecretKey = "<snip>"
BucketName = "<snip>"
BucketLocation = "us-east-1"
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "ruby:2.7"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = true
[runners.machine]
IdleCount = 1
IdleTime = 1800
MaxBuilds = 10
MachineDriver = "amazonec2"
MachineName = "gitlab-docker-machine-%s"
MachineOptions = [
"amazonec2-access-key=<snip>",
"amazonec2-secret-key=<snip>",
"amazonec2-region=us-east-1",
"amazonec2-vpc-id=<snip>",
"amazonec2-subnet-id=<snip>",
"amazonec2-zone=c",
"amazonec2-ssh-user=<snip>",
"amazonec2-use-private-address=true",
"amazonec2-tags=runner-manager-name,<snip>,gitlab,true,gitlab-runner-autoscale,true",
"amazonec2-security-group=<snip>",
"amazonec2-instance-type=m4.xlarge",
"amazonec2-ami=ami-052efd3df9dad4825",
"amazonec2-request-spot-instance=true",
"amazonec2-spot-price=0.15",
]
[[runners.machine.autoscaling]]
Periods = ["* * 9-17 * * mon-fri *"]
IdleCount = 3
IdleTime = 3600
Timezone = "<snip>"
[[runners.machine.autoscaling]]
Periods = ["* * * * * sat,sun *"]
IdleCount = 1
IdleTime = 60
Timezone = "<snip>"
Used GitLab Runner version
Version: 15.2.1
Git revision: 32fc1585
Git branch: 15-2-stable
GO version: go1.17.9
Built: 2022-07-26T21:21:20+0000
OS/Arch: linux/amd64