The same System ID for different Gitlab Runner, in situation where runners work on AWS EC2 created from the same AMI
Summary
Job runner has the same ID system for all instances if they are running on AWS EC2 servers in case EC2 was built on the basis of the same AMI image. This means I can't register a few job runners. When I try to register, I get the following information: WARNING: A runner with this system ID and token has already been registered.
Steps to reproduce
- Create create "Group runner" and copy "Token" to Terraform file (to use in "gitlab registry" comand)
- Create several EC2 for example using Terraform
....
resource "aws_instance" "BaseShellRunner" {
depends_on = [aws_network_interface.BaseShellRunnersEC2Interface]
count = 5 # five instances for Job runner
ami = var.JobRunnerAMI # one AMI for several instances
instance_type = var.BaseShellRunnerEC2Type
launch_template {
id = aws_launch_template.IMDSv2LaunchTemplate.id
version = 1
}
ebs_block_device {
device_name = "/dev/xvda"
encrypted = true
volume_type = "gp3"
delete_on_termination = true
volume_size = var.BaseShellRunnerEC2EBSSize
}
iam_instance_profile = aws_iam_instance_profile.AccSystemManagerProfile.id
network_interface {
device_index = 0
network_interface_id = aws_network_interface.BaseShellRunnersEC2Interface[count.index].id
}
# registration token for 'base' subgroup
user_data = <<EOF
#!/bin/bash
apt update
apt install -y gitlab-runner
gitlab-runner register --non-interactive --url https://gitlab.com --token glrt-hD35FFDDbqXaifnzxNL --executor shell --docker-image alpine:latest
usermod -aG docker gitlab-runner
EOF
}
- During EC2 startup (the same message can be got when 'register command' is executed on EC2) I've got:
...
Created missing unique system ID system_id=s_2b5d72ae1c91
WARNING: A runner with this system ID and token has already been registered.
Verifying runner... is valid runner=hD35MgnYg
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
...
as a result I've only one job runner when I display list runners https://gitlab.com/groups//-/runners/#/
What is the current bug behavior?
Because each Job Runner has the same system id, cannot register several instances of job runners to one job runner group.
What is the expected correct behavior?
When I enter
https://gitlab.com/groups//-/runners/#/
I should see several job runners
Relevant logs and/or screenshots
Edited by Michał Szymański
