Codeberg/Community
54
325
Fork
You've already forked Community
12

Automatic Removal of Dynamic Forgejo Runners #2173

Open
opened 2025年10月13日 15:33:38 +02:00 by aahlenst · 3 comments

Comment

Forgejo allows to register Forgejo Runners dynamically. I use that functionality to create single-use runners on-demand in response to pending jobs that I obtain by polling /orgs/{org}/actions/runners/jobs and /orgs/{org}/actions/runners/jobs. Those runners have unique names to prevent conflicts. Forgejo offers no API to remove those runners. But I can enable the cron job Cleanup Offline Runners that removes them automatically after a configurable amount of time.

On Codeberg, I can do the same. But the stale runners pile up because Cleanup Offline Runners is not enabled.

It would be great if Codeberg could remove those stale runners automatically as well.

Simply enabling Cleanup Offline Runners might be problematic for some people. For example, I would not want my persistent runner to be removed just because it happens to be offline. Therefore, having some mechanism to opt-in on an {organization,user,repository} basis would be great. Furthermore, it would be nice if there was a possibility to mark a runner as "dynamic" which would prevent persistent runners from being removed even if automatic removal of offline runners were enabled. I'd welcome that functionality in Forgejo as well.

Alternatively, having an API for runner removal would work as well.

### Comment Forgejo allows to register Forgejo Runners dynamically. I use that functionality to create single-use runners on-demand in response to pending jobs that I obtain by polling `/orgs/{org}/actions/runners/jobs` and `/orgs/{org}/actions/runners/jobs`. Those runners have unique names to prevent conflicts. Forgejo offers no API to remove those runners. But I can enable the cron job [Cleanup Offline Runners](https://forgejo.org/docs/latest/admin/config-cheat-sheet/#cron---cleanup-offline-runners-croncleanup_offline_runners) that removes them automatically after a configurable amount of time. On Codeberg, I can do the same. But the stale runners pile up because Cleanup Offline Runners is not enabled. It would be great if Codeberg could remove those stale runners automatically as well. Simply enabling Cleanup Offline Runners might be problematic for some people. For example, I would not want my persistent runner to be removed just because it happens to be offline. Therefore, having some mechanism to opt-in on an {organization,user,repository} basis would be great. Furthermore, it would be nice if there was a possibility to mark a runner as "dynamic" which would prevent persistent runners from being removed even if automatic removal of offline runners were enabled. I'd welcome that functionality in Forgejo as well. Alternatively, having an API for runner removal would work as well.
Owner
Copy link

I suggest to enable the cron job for Codeberg, targetting runners that are offline for at least 14 days. It will prevent unbounded growth of the list. 14 days seems like a reasonable amount to fix and reconnect persistent runners that stopped working or are not intended to be online all the time. Maybe 30 days could also work?

AFAIK "removing" a runner does not really free up resources. It is still in the database and no data is removed. The only benefit is hiding it from the list of runners.

@aahlenst Could yo elalaborate on the problem you are facing? Is the list of offline runners a problem for you? Why? In which cases do you access it? I'm rather thinking in the direction of hiding inactive runners, but still keeping them accessible. I see no need to permanently disable a runner.

I suggest to enable the cron job for Codeberg, targetting runners that are offline for at least 14 days. It will prevent unbounded growth of the list. 14 days seems like a reasonable amount to fix and reconnect persistent runners that stopped working or are not intended to be online all the time. Maybe 30 days could also work? AFAIK "removing" a runner does not really free up resources. It is still in the database and no data is removed. The only benefit is hiding it from the list of runners. @aahlenst Could yo elalaborate on the problem you are facing? Is the list of offline runners a problem for you? Why? In which cases do you access it? I'm rather thinking in the direction of hiding inactive runners, but still keeping them accessible. I see no need to permanently disable a runner.

In my case, a single runner is used exactly once and never again. So there's no point in keeping them around. They only occupy resources. Having 10,000 dead runners in a single project seems wasteful.

I access the list of runners to manage persistent runners. If the list is full of stale dynamic runners, I have to use the search functionality to find them.

However, I wouldn't consider any of those issues to be a real problem, only an inconvenience.

In my case, a single runner is used exactly once and never again. So there's no point in keeping them around. They only occupy resources. Having 10,000 dead runners in a single project seems wasteful. I access the list of runners to manage persistent runners. If the list is full of stale dynamic runners, I have to use the search functionality to find them. However, I wouldn't consider any of those issues to be a real problem, only an inconvenience.
Owner
Copy link

As I said, as far as I know there are no resources "freed" on our side by the cron job. they just manage visibility.

As I said, as far as I know there are no resources "freed" on our side by the cron job. they just manage visibility.
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
accessibility

Reduces accessibility and is thus a "bug" for certain user groups on Codeberg.
bug

Something is not working the way it should. Does not concern outages.
bug
infrastructure

Errors evidently caused by infrastructure malfunctions or outages
Codeberg

This issue involves Codeberg's downstream modifications and settings and/or Codeberg's structures.
contributions welcome

Please join the discussion and consider contributing a PR!
docs

No bug, but an improvement to the docs or UI description will help
duplicate

This issue or pull request already exists
enhancement

New feature
infrastructure

Involves changes to the server setups, use `bug/infrastructure` for infrastructure-related user errors.
legal

An issue directly involving legal compliance
licence / ToS

involving questions about the ToS, especially licencing compliance
please chill
we are volunteers

Please consider editing your posts and remember that there is a human on the other side. We get that you are frustrated, but it's harder for us to help you this way.
public relations

Things related to Codeberg's external communication
question

More information is needed
question
user support

This issue contains a clearly stated problem. However, it is not clear whether we have to fix anything on Codeberg's end, but we're helping them fix it and/or find the cause.
s/Forgejo

Related to Forgejo. Please also check Forgejo's issue tracker.
s/Forgejo/migration

Migration related issues in Forgejo
s/Pages

Issues related to the Codeberg Pages feature
s/Weblate

Issue is related to the Weblate instance at https://translate.codeberg.org
s/Woodpecker

Woodpecker CI related issue
security

involves improvements to the sites security
service

Add a new service to the Codeberg ecosystem (instead of implementing into Gitea)
upstream

An open issue or pull request to an upstream repository to fix this issue (partially or completely) exists (i.e. Gitea, Forgejo, etc.)
wontfix

Codeberg's current set of contributors are not planning to spend time on delegating this issue.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 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
Codeberg/Community#2173
Reference in a new issue
Codeberg/Community
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?