aboutsummaryrefslogtreecommitdiffstats
path: root/services/actions
diff options
context:
space:
mode:
authorFrancesco Antognazza <francesco.antognazza@gmail.com>2023-10-02 23:09:26 +0200
committerGitHub <noreply@github.com>2023-10-02 23:09:26 +0200
commitbc21723717a00888722c86641b70371a811867f9 (patch)
tree31ea636cc61af5e26c604bcd197c06b4cd9b47f8 /services/actions
parentdfa4e5857fe9d8f113cf50d4c7fda094f0f30b74 (diff)
downloadgitea-bc21723717a00888722c86641b70371a811867f9.tar.gz
gitea-bc21723717a00888722c86641b70371a811867f9.zip
Make Actions tasks/jobs timeouts configurable by the user (#27400)
With this PR we added the possibility to configure the Actions timeouts values for killing tasks/jobs. Particularly this enhancement is closely related to the `act_runner` configuration reported below: ``` # The timeout for a job to be finished. # Please note that the Gitea instance also has a timeout (3h by default) for the job. # So the job could be stopped by the Gitea instance if it's timeout is shorter than this. timeout: 3h ``` --- Setting the corresponding key in the INI configuration file, it is possible to let jobs run for more than 3 hours. Signed-off-by: Francesco Antognazza <francesco.antognazza@gmail.com>
Diffstat (limited to 'services/actions')
-rw-r--r--services/actions/clear_tasks.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/services/actions/clear_tasks.go b/services/actions/clear_tasks.go
index d2893e4f23..7c7043c42f 100644
--- a/services/actions/clear_tasks.go
+++ b/services/actions/clear_tasks.go
@@ -12,20 +12,15 @@ import (
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/actions"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
)
-const (
- zombieTaskTimeout = 10 * time.Minute
- endlessTaskTimeout = 3 * time.Hour
- abandonedJobTimeout = 24 * time.Hour
-)
-
// StopZombieTasks stops the task which have running status, but haven't been updated for a long time
func StopZombieTasks(ctx context.Context) error {
return stopTasks(ctx, actions_model.FindTaskOptions{
Status: actions_model.StatusRunning,
- UpdatedBefore: timeutil.TimeStamp(time.Now().Add(-zombieTaskTimeout).Unix()),
+ UpdatedBefore: timeutil.TimeStamp(time.Now().Add(-setting.Actions.ZombieTaskTimeout).Unix()),
})
}
@@ -33,7 +28,7 @@ func StopZombieTasks(ctx context.Context) error {
func StopEndlessTasks(ctx context.Context) error {
return stopTasks(ctx, actions_model.FindTaskOptions{
Status: actions_model.StatusRunning,
- StartedBefore: timeutil.TimeStamp(time.Now().Add(-endlessTaskTimeout).Unix()),
+ StartedBefore: timeutil.TimeStamp(time.Now().Add(-setting.Actions.EndlessTaskTimeout).Unix()),
})
}
@@ -81,7 +76,7 @@ func stopTasks(ctx context.Context, opts actions_model.FindTaskOptions) error {
func CancelAbandonedJobs(ctx context.Context) error {
jobs, _, err := actions_model.FindRunJobs(ctx, actions_model.FindRunJobOptions{
Statuses: []actions_model.Status{actions_model.StatusWaiting, actions_model.StatusBlocked},
- UpdatedBefore: timeutil.TimeStamp(time.Now().Add(-abandonedJobTimeout).Unix()),
+ UpdatedBefore: timeutil.TimeStamp(time.Now().Add(-setting.Actions.AbandonedJobTimeout).Unix()),
})
if err != nil {
log.Warn("find abandoned tasks: %v", err)