feat: add an unregister command #182

Open
opened 2024-04-18 08:32:26 +00:00 by viceice · 7 comments
Owner

I'm running the runner inside kubernetes and everytime the pod get's recreated i get a new runner.
Now the old runner pod get's removed but it's still registered in forgejo.

So i like to add a shutdown hook which will unregister the runner.

I'm running the runner inside kubernetes and everytime the pod get's recreated i get a new runner. Now the old runner pod get's removed but it's still registered in forgejo. So i like to add a shutdown hook which will unregister the runner. - https://codeberg.org/forgejo/forgejo/issues/1030
earl-warren changed title from Add an unregister command to feat: add an unregister command 2025-07-01 15:50:39 +00:00

This is a very needed thing when running dynamically provisioned runners. I just had to spend way to much time manually de-registering over 100 runner pods from the UI which was painful because the UI doesn't provide a way to remove multiple runners at once.

This is a very needed thing when running dynamically provisioned runners. I just had to spend way to much time manually de-registering over 100 runner pods from the UI which was painful because the UI doesn't provide a way to remove multiple runners at once.
Contributor

Bumped the priority.

Bumped the priority.
Author
Owner

wrongly closed from merge

wrongly closed from merge
viceice reopened this issue 2025-07-28 17:28:08 +00:00
Contributor

good catch

good catch
Member

@viceice The issue you linked talks about HTTP APIs. Is that sufficient for your use case or do you want to execute forgejo-runner unregister in a Kubernetes PreStop hook?

@viceice The issue you linked talks about HTTP APIs. Is that sufficient for your use case or do you want to execute `forgejo-runner unregister` in a Kubernetes PreStop hook?

HTTP API is a prerequisite to having an unregister command. If the API is added, we can at least script a preStop with curl and an addtional configmap to provide the script, but the end goal should be an unregister command.

I can imagine there are needs for dynamically priovisioned runners outside of Kube as well.

HTTP API is a prerequisite to having an unregister command. If the API is added, we can at least script a preStop with curl and an addtional configmap to provide the script, but the end goal should be an unregister command. I can imagine there are needs for dynamically priovisioned runners outside of Kube as well.
Member

@Routhinator wrote in #182 (comment):

HTTP API is a prerequisite to having an unregister command.

The runner talks to Forgejo using GRPC. I don't think it calls the HTTP API at any time.

If the API is added, we can at least script a preStop with curl and an addtional configmap to provide the script, but the end goal should be an unregister command.

An endpoint to delete runners exists in the development version of Forgejo. It would be awesome if you could try it and provide feedback.

I don't think it will be easy to do with curl because you'd need to know whether it's a global, organization, user, or repository runner to call the right endpoint. I don't think we can infer this information from the .runner file or the local configuration. So we'd need another endpoint that could provide that information.

I can imagine there are needs for dynamically priovisioned runners outside of Kube as well.

From what I could gather so far, forgejo-runner register only makes sense for people with Kubernetes or a similar system that can keep the runner registration token secret. For everyone else, corresponding HTTP APIs are being developed.


What are the requirements for a forgejo-runner unregister command?

What I have so far:

  • forgejo-runner unregister should be a no-op with exit code 0 (and a terminal message?) if there's no .runner file.
  • forgejo-runner unregister should work with the credentials stored in the .runner file.
  • If forgejo-runner unregister fails for some reason, it should exit with a code > 0.
  • Upon success, forgejo-runner unregister should remove the .runner file.
@Routhinator wrote in https://code.forgejo.org/forgejo/runner/issues/182#issuecomment-69876: > HTTP API is a prerequisite to having an unregister command. The runner talks to Forgejo using GRPC. I don't think it calls the HTTP API at any time. > If the API is added, we can at least script a preStop with curl and an addtional configmap to provide the script, but the end goal should be an unregister command. An endpoint to delete runners exists in the development version of Forgejo. It would be awesome if you could try it and provide feedback. I don't think it will be easy to do with `curl` because you'd need to know whether it's a global, organization, user, or repository runner to call the right endpoint. I don't think we can infer this information from the `.runner` file or the local configuration. So we'd need another endpoint that could provide that information. > I can imagine there are needs for dynamically priovisioned runners outside of Kube as well. From what I could gather so far, `forgejo-runner register` only makes sense for people with Kubernetes or a similar system that can keep the runner registration token secret. For everyone else, corresponding HTTP APIs are being developed. --- What are the requirements for a `forgejo-runner unregister` command? What I have so far: * `forgejo-runner unregister` should be a no-op with exit code 0 (and a terminal message?) if there's no `.runner` file. * `forgejo-runner unregister` should work with the credentials stored in the `.runner` file. * If `forgejo-runner unregister` fails for some reason, it should exit with a code > 0. * Upon success, `forgejo-runner unregister` should remove the `.runner` file.
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/runner#182
No description provided.