mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-05-11 10:23:24 +02:00
fix: ensure dbfs_data is cleaned up after task completion (#952)
Fixes #950. After #819, the daemon flushes logs eagerly on the job-result entry (via the `stateNotify` path), so `Close()` typically runs `ReportLog(true)` with an empty buffer. Gitea's `UpdateLog` handler short-circuits on `len(Rows)==0` before honoring `NoMore`, so the final request never runs `TransferLogs` and `dbfs_data` rows leak. The server-side short-circuit is latent since the original Actions implementation in 2023; #819 made it deterministically reachable. Workaround: inject a sentinel row in `Close()` after the daemon has exited so the final `UpdateLog` always carries at least one row. Done after the daemon waits so the sentinel can't be flushed before `ReportLog(true)` reads it. https://github.com/go-gitea/gitea/pull/37631 drops the empty-rows short-circuit when `NoMore=true`; that would work with or without this PR. Reviewed-on: https://gitea.com/gitea/runner/pulls/952 Reviewed-by: Nicolas <bircni@icloud.com> Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com> Co-authored-by: silverwind <me@silverwind.io> Co-committed-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -416,6 +416,21 @@ func (r *Reporter) Close(lastWords string) error {
|
||||
log.Error("No Response from RunDaemon for 60s, continue best effort")
|
||||
}
|
||||
|
||||
// Gitea's UpdateLog short-circuits on len(Rows)==0 before honoring NoMore,
|
||||
// so a final empty request never runs TransferLogs and dbfs_data leaks.
|
||||
// Inject a sentinel row after the daemon has exited so it can't be flushed
|
||||
// before ReportLog(true).
|
||||
// TODO: Remove after https://github.com/go-gitea/gitea/pull/37631 is in all
|
||||
// supported branches, e.g. v1.28+.
|
||||
r.stateMu.Lock()
|
||||
if len(r.logRows) == 0 {
|
||||
r.logRows = append(r.logRows, &runnerv1.LogRow{
|
||||
Time: timestamppb.Now(),
|
||||
Content: "",
|
||||
})
|
||||
}
|
||||
r.stateMu.Unlock()
|
||||
|
||||
// Report the job outcome even when all log upload retry attempts have been exhausted
|
||||
return errors.Join(
|
||||
retry.Do(func() error {
|
||||
|
||||
Reference in New Issue
Block a user