Handle registration for runners created in GitLab UI
What does this MR do?
This MR prepares gitlab-runner register
command to accept a glrt-
-prefixed authentication token in place of a registration token. In that case, it will call VerifyRunner
instead of RegisterRunner
and write out the new configuration.
Why was this MR needed?
To cover the plan laid out in the blueprint to accept an authentication token in order to minimize the changes that users need to make to their setup.
What's the best way to test this MR?
https://www.loom.com/share/417024c21ed4430bb5369880a0531fce
An up-to-date GDK server is needed to test this MR, but in case you don't have that, here are the steps:
-
Enable the feature flag in the Rails console:
Feature.enable(: create_runner_workflow)
-
Create a runner in the GDK (UI for it is not yet available, so you'll need to use the Rails console
gdk console
):Ci::Runners::CreateRunnerService.new(user: User.find(1), type: nil, params: {}).execute.payload[:runner].token
-
Register the runner given the new style
glrt-
runner token obtained fromgdk.test
:gitlab-runner register -config ~/.gitlab-runner/config.gdk.toml --non-interactive --executor "docker" --docker-image "ubuntu:latest" --url "http://gdk.test:3000/" --description "project test runner" --registration-token="glrt-Mxs8FE84XoupAykHFEiP"
This results in the following section being added to the config:
Generated section of config.toml
[[runners]] name = "project test runner" url = "http://gdk.test:3000/" id = 1002 token = "glrt-Mxs8FE84XoupAykHFEiP" token_obtained_at = 2023-02-17T10:04:48Z token_expires_at = 0001-01-01T00:00:00Z executor = "docker" [runners.cache] MaxUploadedArchiveSize = 0 [runners.docker] tls_verify = false image = "ubuntu:latest" privileged = false disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/cache"] shm_size = 0
-
The registration with a regular registration token should also work as before.