Add DELETE /runners/managers endpoint
What does this MR do and why?
Describe in detail what your merge request does and why.
This MR adds a DELETE /runners/managers
endpoint, similar to the DELETE /runners
endpoint (used by the gitlab-runner unregister
command) but accepting an additional system_id
attribute. The endpoint locates the correct ci_runner_machines
record and deletes it.
NOTE: The command line counterpart (to use DELETE /runners/managers
endpoint in the case of a glrt-
token) is !118212 (merged)
Closes #408206 (closed)
Alternative solutions considered
- Having
DELETE /runners
return an error ifsystem_id
is not present. This was ruled out because oldgitlab-runner
clients automatically call the endpoint if registration fails. This would have caused the runner that was created in the UI to be destroyed. - Having
DELETE /runners
return a success code ifsystem_id
is not present. This was ruled out because it would introduce a specific behavior that is only needed in the short term, and would cause the endpoint to diverge significantly from the matching GraphQL mutation (runnerDelete
).
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
NOTE: This MR relies on behavior introduced in gitlab-runner!4053 (merged) (without that MR, it should delete the entry from config.toml
, but not from the ci_runner_machines
table)
-
On the Rails console, enable the
:create_runner_workflow_for_admin
FF:Feature.enable(:create_runner_workflow_for_admin)
-
Create an instance runner in the web UI: http://gdk.test:3000/admin/runners
-
Register the instance runner according to the instructions provided.
-
Unregister the instance runner with `gitlab-runner':
gitlab-runner unregister --name '<runner name from gitlab-runner --list>'
-
Ensure that the runner manager disappeared both from
config.toml
and from the database. To check the database, you could do the following on the Rails console:# This should return an empty collection Ci::Runner.find_by_token("<runner-token-here").runner_machines
Also, if you navigate back to the runners page, you should still see the online runner there (it just won't have any runner managers associated with it).
-
To ensure that the old behavior is still present, make sure that unregistering a runner that was registered in the legacy fashion (one that is not prefixed with
glrt-
) does delete the runner record. I.e.# This should not find a record Ci::Runner.find_by_token("<runner-token-here")
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.