Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Un-register gitlab-runner on Ubuntu not working

I'm trying to unregister gitlab-runner on EC2 instance (Ubuntu machine) with the following command:

sudo gitlab-runner --debug unregister --token [RUNNER-TOKEN] --url [RUNNER-URL]

and I'm getting following error:

Runtime platform                                    arch=amd64 os=linux pid=2374 revision=6fbc7474 version=13.1.1
Checking runtime mode                               GOOS=linux uid=0
Running in system-mode.

Dialing: tcp gitlab.com:443 ...
ERROR: Unregistering runner from GitLab forbidden   runner=xv2Ng6Tc
FATAL: Failed to unregister runner
like image 271
ImFarhad Avatar asked Jul 19 '20 07:07

ImFarhad


3 Answers

Make sure that you're using the entire SHA, not the partial one listed on the Gitlab CI runners list.

This can be found by running sudo gitlab-runner list on the machine with the runner installed.

If you've already removed the runner in the gitlab runners page, it will still be present on the gitlab-runner machine (check with the command sudo gitlab-runner list).

You can then unregister it from the config.toml using the command:

gitlab-runner verify --delete

Or manually, by running:

  • sudo gitlab-runner stop
  • sudo vi /etc/gitlab-runner/config.toml # update the runners section
  • sudo gitlab-runner start
like image 137
Preston Avatar answered Oct 27 '22 15:10

Preston


For MacOS and Ubuntu

If you have already removed it from the Runners section in your project settings then you are no longer be able to unregister with command. Then what you can do is to delete them from your host as below:

gitlab-runner verify --delete 

This will remove all the unregistered/removed runners from your host machine and will update config.toml file.


If you haven't removed it from Runners section in your project settings(Settings -> CI/CD -> Runners), then you can unregister it from your host like below:

gitlab-runner unregister runner_id/name

or unregister all runners,

gitlab-runner unregister --all-runners

Hope this will help to somebody. cheers !!!

like image 13
Chanaka Anuradh Caldera Avatar answered Oct 27 '22 13:10

Chanaka Anuradh Caldera


I experienced the same issue when I tried to remove a runner that was removed directly from Gitlab settings of the project. It seems that "Remove runner"'s button removes the runner from Gitlab but not from your gitlab-runner, which is absolutely fine since I don't want Gitlab to mess up to my on-premise gitlab-runner.

Cursed button here

In order to fix that, I stopped the gitlab-runner service, removed the runner directly from the config file (it is usually located in /etc/gitlab-runner/config.toml) and started the service again.

I hope I could help you ;)

like image 4
Suzaku Avatar answered Oct 27 '22 13:10

Suzaku