Allow CI image option to override base image name (VirtualBox & Parallels)
What does this MR do?
Allows to override base_name
(TOML's) with a value from image
(YAML's). It allows to use a single Runner for running different VMs.
base_name
parameter present for both VirtualBox & Parallels Executors:
- https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersvirtualbox-section
- https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersparallels-section
By default, for the sake of backward compatibility, YAML's image
is ignored. Only VM specified by TOML's base_name
is allowed to be used. If any image
which is not equal to base_name
is specified in YAML file a user is shown with a warning:
WARNING: .gitlab-ci.yml provided image "test2" is ignored, default VM image is being used instead.
In order to make overriding possible allowed_images
parameter (a new one) needs to be provided. allowed_images
is a list of regular expressions, an example is below:
[runners.virtualbox]
base_name = "test1"
allowed_images = ["^test[1-2]$"]
This configuration allows to use test1
and test2
VM images, everything else is forbidden. If base_name
is not explicitly allowed by allowed_images
it is assumed to be allowed implicitly.
If anything which is not allowed is tried to be referenced the following error messages is shown:
ERROR: The test3 is not present on list of allowed images
- ^test[1-2]$
Please check runner's configuration
ERROR: Preparation failed: invalid image
In order to allow usage of any image the following configuration can be used:
[runners.virtualbox]
base_name = "test1"
allowed_images = [".*"]
Why was this MR needed?
Without it a separate Runner must be registered for each VM image. For example I have 6 physical Mac devices and 3 different VM images. Each physical Mac have all 3 VMs deployed. Depending on a being built project a different VM must be used. To give a chance to users to use any VM image with any physical Runner I had to register 18 logical Runners. This approach does not scale enough. Having 10 physical devices with 10 VM images I will have to register 100 Runners.
In a real life I have the following TOML configuration file on each physical Mac device:
concurrent = 1
check_interval = 0
[[runners]]
name = "***************"
output_limit = 100000
url = "*************************************"
token = "******************************"
executor = "parallels"
[runners.ssh]
user = "runner"
password = "1234"
host = "localhost"
[runners.parallels]
base_name = "Image1"
disable_snapshots = false
[runners.cache]
[[runners]]
name = "***************"
output_limit = 100000
url = "*************************************"
token = "******************************"
executor = "parallels"
[runners.ssh]
user = "runner"
password = "1234"
host = "localhost"
[runners.parallels]
base_name = "Image2"
disable_snapshots = false
[runners.cache]
[[runners]]
name = "***************"
output_limit = 100000
url = "*************************************"
token = "******************************"
executor = "parallels"
[runners.ssh]
user = "runner"
password = "1234"
host = "localhost"
[runners.parallels]
base_name = "Image3"
disable_snapshots = false
[runners.cache]
Are there points in the code the reviewer needs to double check?
At the moment I want only an idea and a drafted implementation to be reviewed. If the idea is accepted the implementation will be cleaned up, documentation will be updated as well.
Does this MR meet the acceptance criteria?
-
Documentation created/updated -
Added tests for this feature/bug -
In case of conflicts with master
- branch was rebased