aboutsummaryrefslogtreecommitdiffstats
path: root/services/actions/clear_tasks.go
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2023-06-29 01:07:29 +0800
committerGitHub <noreply@github.com>2023-06-28 19:07:29 +0200
commit6daf21c9b722e31ea5e3b1ec48caa69327580abd (patch)
treed689df26a38ed3a6124d475613c4f899127aa7bf /services/actions/clear_tasks.go
parentb6693a2c9a6010463950bbd89a2bfee88bde5e5f (diff)
downloadgitea-6daf21c9b722e31ea5e3b1ec48caa69327580abd.tar.gz
gitea-6daf21c9b722e31ea5e3b1ec48caa69327580abd.zip
Fix content holes in Actions task logs file (#25560)
Fix #25451. Bugfixes: - When stopping the zombie or endless tasks, set `LogInStorage` to true after transferring the file to storage. It was missing, it could write to a nonexistent file in DBFS because `LogInStorage` was false. - Always update `ActionTask.Updated` when there's a new state reported by the runner, even if there's no change. This is to avoid the task being judged as a zombie task. Enhancement: - Support `Stat()` for DBFS file. - `WriteLogs` refuses to write if it could result in content holes. --------- Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'services/actions/clear_tasks.go')
-rw-r--r--services/actions/clear_tasks.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/services/actions/clear_tasks.go b/services/actions/clear_tasks.go
index 0616a5fc0d..d2893e4f23 100644
--- a/services/actions/clear_tasks.go
+++ b/services/actions/clear_tasks.go
@@ -56,12 +56,20 @@ func stopTasks(ctx context.Context, opts actions_model.FindTaskOptions) error {
return nil
}); err != nil {
log.Warn("Cannot stop task %v: %v", task.ID, err)
- // go on
- } else if remove, err := actions.TransferLogs(ctx, task.LogFilename); err != nil {
+ continue
+ }
+
+ remove, err := actions.TransferLogs(ctx, task.LogFilename)
+ if err != nil {
log.Warn("Cannot transfer logs of task %v: %v", task.ID, err)
- } else {
- remove()
+ continue
+ }
+ task.LogInStorage = true
+ if err := actions_model.UpdateTask(ctx, task, "log_in_storage"); err != nil {
+ log.Warn("Cannot update task %v: %v", task.ID, err)
+ continue
}
+ remove()
}
CreateCommitStatus(ctx, jobs...)