Skip to content

Conversation

@Zettat123
Copy link
Contributor

@Zettat123 Zettat123 commented Oct 29, 2025

Related issues: #35780, #35782

Rerunning a job or a run is only allowed when the job is done and the run is done.

Related PR: #34970

resp.State.Run.CanRerun = run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)

We don't need to check run status again in rerunJob because the run status has been changed before rerunJob.


In fact, the bug described in the above issues will not occur on the main branch. Because getRunJobs is called before updating the run.

job, jobs := getRunJobs(ctx, runIndex, jobIndex)
if ctx.Written() {
return
}
// reset run's start and stop time when it is done
if run.Status.IsDone() {
run.PreviousDuration = run.Duration()
run.Started = 0
run.Stopped = 0
run.Status = actions_model.StatusWaiting

So the run status that rerunJob checks is the old status.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 29, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Oct 29, 2025
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 29, 2025
@wxiaoguang
Copy link
Contributor

A lot of changes are 1.26 only, so maybe you need to manually backport the fix

@Zettat123
Copy link
Contributor Author

A lot of changes are 1.26 only, so maybe you need to manually backport the fix

Yes. I think the backport needs to be fixed manually.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 30, 2025
@wxiaoguang wxiaoguang enabled auto-merge (squash) October 30, 2025 00:56
@wxiaoguang wxiaoguang merged commit 3ab8ae5 into go-gitea:main Oct 30, 2025
26 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Oct 30, 2025
Zettat123 added a commit to Zettat123/gitea that referenced this pull request Oct 30, 2025
Related issues: go-gitea#35780, go-gitea#35782

Rerunning a job or a run is only allowed when the job is done and the
run is done.

Related PR: go-gitea#34970
@Zettat123 Zettat123 added the backport/done All backports for this PR have been created label Oct 30, 2025
mithileshgupta12 pushed a commit to mithileshgupta12/gitea that referenced this pull request Oct 30, 2025
Related issues: go-gitea#35780, go-gitea#35782 

Rerunning a job or a run is only allowed when the job is done and the
run is done.

Related PR: go-gitea#34970
silverwind pushed a commit that referenced this pull request Oct 30, 2025
Backport #35783

Fix #35780, fix #35782 

Rerunning a job or a run is only allowed when the job is done and the
run is done.

Related PR: #34970


https://github.com/go-gitea/gitea/blob/98ff7d077376db1225f266095788c6bd9414288a/routers/web/repo/actions/view.go#L239

We don't need to check run status again in `rerunJob` because the run
status has been changed before `rerunJob`.

---

In fact, the bug described in the above issues will not occur on the
main branch. Because `getRunJobs` is called before updating the run.


https://github.com/go-gitea/gitea/blob/98ff7d077376db1225f266095788c6bd9414288a/routers/web/repo/actions/view.go#L425-L435

So the run status that `rerunJob` checks is the old status.

---------

Co-authored-by: wxiaoguang <[email protected]>
techknowlogick pushed a commit that referenced this pull request Nov 4, 2025
#35783 fixes an actions rerun bug. Due to this bug, some runs may be
incorrectly marked as `StatusWaiting` even though all the jobs are in
done status. These runs cannot be run or cancelled. This PR adds a new
doctor command to fix the inconsistent run status.

```
gitea doctor check --run fix-actions-unfinished-run-status --fix
```

Thanks to @ChristopherHX  for the test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.25 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants