mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-24 01:50:51 +00:00
feat: auto cleanup of offline runners (#7803)
Some checks failed
/ release (push) Has been cancelled
testing / backend-checks (push) Has been cancelled
testing / frontend-checks (push) Has been cancelled
testing / test-unit (push) Has been cancelled
testing / test-remote-cacher (garnet) (push) Has been cancelled
testing / test-remote-cacher (redict) (push) Has been cancelled
testing / test-mysql (push) Has been cancelled
testing / test-pgsql (push) Has been cancelled
testing / test-sqlite (push) Has been cancelled
testing / test-e2e (push) Has been cancelled
testing / test-remote-cacher (redis) (push) Has been cancelled
testing / test-remote-cacher (valkey) (push) Has been cancelled
testing / security-check (push) Has been cancelled
Some checks failed
/ release (push) Has been cancelled
testing / backend-checks (push) Has been cancelled
testing / frontend-checks (push) Has been cancelled
testing / test-unit (push) Has been cancelled
testing / test-remote-cacher (garnet) (push) Has been cancelled
testing / test-remote-cacher (redict) (push) Has been cancelled
testing / test-mysql (push) Has been cancelled
testing / test-pgsql (push) Has been cancelled
testing / test-sqlite (push) Has been cancelled
testing / test-e2e (push) Has been cancelled
testing / test-remote-cacher (redis) (push) Has been cancelled
testing / test-remote-cacher (valkey) (push) Has been cancelled
testing / security-check (push) Has been cancelled
Fixes #7646 Adds a cron job to cleanup action runners that have been offline or inactive for X amount of time. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7803 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Julian Schlarb <julian.schlarb@denktmit.de> Co-committed-by: Julian Schlarb <julian.schlarb@denktmit.de>
This commit is contained in:
parent
4d44ae39e1
commit
4b6ccbd631
8 changed files with 274 additions and 2 deletions
|
@ -5,6 +5,7 @@ package cron
|
|||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
user_model "forgejo.org/models/user"
|
||||
"forgejo.org/modules/setting"
|
||||
|
@ -20,6 +21,7 @@ func initActionsTasks() {
|
|||
registerCancelAbandonedJobs()
|
||||
registerScheduleTasks()
|
||||
registerActionsCleanup()
|
||||
registerOfflineRunnersCleanup()
|
||||
}
|
||||
|
||||
func registerStopZombieTasks() {
|
||||
|
@ -74,3 +76,22 @@ func registerActionsCleanup() {
|
|||
return actions_service.Cleanup(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func registerOfflineRunnersCleanup() {
|
||||
RegisterTaskFatal("cleanup_offline_runners", &CleanupOfflineRunnersConfig{
|
||||
BaseConfig: BaseConfig{
|
||||
Enabled: false,
|
||||
RunAtStart: false,
|
||||
Schedule: "@midnight",
|
||||
},
|
||||
GlobalScopeOnly: true,
|
||||
OlderThan: time.Hour * 24,
|
||||
}, func(ctx context.Context, _ *user_model.User, cfg Config) error {
|
||||
c := cfg.(*CleanupOfflineRunnersConfig)
|
||||
return actions_service.CleanupOfflineRunners(
|
||||
ctx,
|
||||
c.OlderThan,
|
||||
c.GlobalScopeOnly,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue