The schedule order cannot tell a conflict: the forge answers 405 'Please try again later' #53
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/gascitypacks!53
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-uuv"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The schedule order now tells a conflicting pull request by what the forge says of the pull request, not by the words of its refusal. Fixes gascitypacks-uuv, found by the Operator's trial of the order (comment on #44, issuecomment-3010).
The problem
Forgejo 17.0.1 answers the merge request of a pull request that conflicts with its base with
405 "Please try again later". "conflict" is not in it, sostrings.Contains(..., "conflict")inschedule.gonever matched, and every conflicting pull request would have become a bead for the Operator instead of going to rework.What changed
On
forge_refusedthe order reads the pull request in-process, with the code ofpr state(fetchPullandmergeability: the pull request alone, no checks, no reviews) and acts onmergeable:not_mergeableauto_merge_troublewith reasonnot_mergeable. Two hours in a row is still the onestuckbead.mergeableordraftforge_refused), as before. The bead and its mail now say what the forge says of the pull request.not_openand so on).error, retried next cycle, exit 1.Which answer of the forge it relies on, and what it does while the forge has not computed it
It relies on
mergeableof the forge's pull request object, a bare boolean. It is false for a conflict, for a conflict check still running (checking) and for a failed check alike, and the API does not say which (README, section "mergeable"). So the order does not try to tell them apart: it takes all three asnot_mergeable, and the three have the same effect, nothing but the clock. A check that was still running is mended by the next cycle (two minutes later, the order asks again): the merge is then scheduled,auto_merge=scheduledis written andauto_merge_troubleis removed. A real conflict staysnot_mergeableand is the rework order's (L13, not built yet) to read from the forge; until then the Operator hears of it at two hours.Two things to know:
mergeableis true) makes one bead for the Operator at once, as every non-conflict refusal did. It is one bead per head, and rare.stuckbead for a conflict stays: it is the clock the order had, and L12 says a pull request that keeps refusing is a bead for the Operator. If you want a conflict never to reach the Operator, even at two hours, say so and it is a two-line change.Not changed
The other steps of the trial (comment on #44) matched, and nothing they cover changed:
scheduled,already_scheduled,merged,head_moved,not_open,wrong_base,missing,foreign,no_diffand the 500 are as they were. The order is still off unlessFORGEJO_SCHEDULE=on. No shell was added.Verification
go vetandgo testinforgejo/assets/forgejo: pass.{"message":"Please try again later"}, run through the realprMergeAnswerandprMergeableagainst the fake forge withmergeablefalse (no bead), true (a bead) and a draft (a bead). Unit tests for each branch above, and for the retry of a check that was still running. The old conflict test, which fed the word "conflict", is replaced.valid=true. README's schedule-order table updated.Bead: gascitypacks-uuv
Review of
492b9b7f20for gascitypacks-uuv. Checks of the head: success.Verdict
pass
Findings
[Unreleased]inCHANGELOG.md. That was right at this head, which was cut before #52 (gascitypacks-c7j,53a9474), and the work bead allows it ("as the repository takes them at your head"). On the currentmainthe README's "Releases" section says a pull request "notes its change in a file of its own in.changelog/… and never editsCHANGELOG.md". It does not block: the v2 checker passes the merged tree (valid=true, since a note added toCHANGELOG.mdcounts formissing-fragment), andchangelog releasefolds a note already under[Unreleased]in with the fragments. Only if the branch is rebased for another reason: move the note into.changelog/schedule-conflict-mergeable.mdunder### Fixed.Verified
docs/handoffs.md(origin/main). 3.11 (d) givesforge_refusedtwo outcomes: a conflict is the rework trigger, and any other refusal is a bead for the Operator.refused()(forgejo/assets/forgejo/schedule.go:367-385) does exactly that. It decides bymergeableand never by the message:not_mergeablerecords onlyauto_merge_troublewith reasonnot_mergeable,mergeable/draftrecords the trouble and makes one bead for the Operator, and when the PR is not open the order does nothing until the next cycle. When the read fails it records troubleerrorand exits 1. The PR description says which forge answer it relies on (themergeableboolean) and what happens while the forge is still checking (the next cycle asks again). This matches the README'smergeablesection: the order never takesnot_mergeableas a conflict on a single read. The only consequence is that no bead is raised.prMergeablereusesfetchPullandmergeabilityfrompr state, so it reads the pull request alone (one GET, no checks or reviews), and an open pull request with nomergeablefield is an error.trouble()keepsSincewhen the reason changes, so the two-hourstuckbead still fires for a conflict that persists. The test checks this: no bead after 5 cycles, onestuckbead attroubleLimit. Once the check finishes, a scheduled answer clears the trouble (TestScheduleAForgeStillCheckingMergeabilityIsMendedByTheNextCycle).TestScheduleOfAConflictTheForgeAnswers405PleaseTryAgainLater, goes through the realprMergeAnswerandprMergeableagainst the fake Forgejo: 405{"message":"Please try again later"}withmergeablefalse gives no bead and troublenot_mergeable, and true or a draft gives one bead. The branches for not open, read error, mergeable and draft each have a unit test. The other steps of the trial (scheduled,already_scheduled,merged,head_moved,not_open,wrong_base,missing,foreign,no_diff, the 500) take the same code path as before, and their tests still pass unchanged.FORGEJO_SCHEDULEis untouched, so the order is still off by default. No shell was added.origin/main(53a9474, which includes #52).README.mdauto-merged.go vet ./...ok;go test ./...ok;go test -race -count=1 ./...ok (inforgejo/). I built the changelog checker from the tagged source ofactions/validate@v2(c19d67d, v2.0.1) and ran it with-base main:valid=true, no findings. I did not run thescriptsjob's shell tests orgc lint: this diff touches neither the shell nor the pack's TOML.