Repository navigation
perf(pipeline): post per-workflow commit statuses once and concurrently - #7024
slayerjain wants to merge 11 commits into
Conversation
Posting one commit status per workflow sequentially delays the start of pipelines with many workflows by tens of seconds (3 rounds x workflows sequential forge calls before start). Post them with bounded concurrency instead, and log a per-phase timing summary (hook parse, config fetch, compile, status publishing, start) to locate remaining latency. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Pipeline creation, approval and restart each posted the full set of per-workflow commit statuses up to three times before the pipeline started (after compile, on the pending transition and in start()), all with identical pending states. Post them once, in start(), and only publish the pubsub events for the earlier transitions. Also harden the start() failure path: the pipeline and its workflows now transition to error and post terminal statuses, instead of leaving the pipeline pending forever. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Account with some automation detected 🤖🧑💻We noticed a mix of typical human activity and some patterns often associated with automation or AI agents. Human? 57% likely to be a human.
Have thoughts about this account? Let the community know. 🕵🏽 Analyzed 300 public events via AgentScan |
|
Surge PR preview deployment succeeded. View it at https://woodpecker-ci-woodpecker-pr-7024.surge.sh |
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7024 +/- ##
==========================================
+ Coverage 67.60% 67.92% +0.31%
==========================================
Files 452 453 +1
Lines 22867 22993 +126
==========================================
+ Hits 15459 15617 +158
+ Misses 7408 7376 -32 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…rder start() queues a pipeline's workflows and then posts a status for each of them from the pipeline's in-memory copy, in which every workflow is still pending. With many workflows that takes a while (about 20s for 87 of them at 4 concurrent posts), and an agent can run a short workflow to the end meanwhile: its Init and Done post running and success, and the pipeline's post of it lands after them with pending. A forge keeps the status posted last, so the workflow shows pending forever. Over 20 pull-request pipelines of one repo, 6 statuses were left pending that way and 182 went back from running to pending while running. Every status post now goes through PostWorkflowStatus, which posts the workflow's (and for a deploy, the pipeline's) state as persisted when the post is sent, and posts one status at a time: every state change is persisted before it is posted, so the post that reaches the forge last carries the latest state. Posts of different workflows still run concurrently; a deploy pipeline's posts, which all set its one deployment, are ordered across its workflows. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
PostWorkflowStatus posts while holding the status's lock, and the forge clients set no HTTP timeout of their own. A hung request therefore held up every later post of the same status, including an agent's Init and Done. For a deploy pipeline, whose workflows all share one lock, the last of N queued posts waited N times as long, and the RPC path's context has no deadline to cut that short. Bound the post itself with a 30s deadline taken once the lock is held, and bound the wait for the lock with the caller's context and a 2m limit, so a post's worst case no longer grows with the queue. Addon forges ignore the context and stay unbounded. Past these bounds delivery is best effort. Abandoning a request does not stop a forge that already received it, so ordering is no longer guaranteed, and a post whose wait is abandoned is dropped without a retry: if the forge hangs for longer than the bound and that post was the last one for its status, the forge keeps the earlier state. Before this, such a post hung indefinitely. Refresh the pipeline's Started/Finished along with its status - Bitbucket Datacenter derives a duration from them - and the workflow's Error, Started and Finished along with its state, which addon forges receive. Tests: a failing test in the release/held pattern returned before releasing its held post, leaving the key locked in the package-global statusLocks and hanging the package to its timeout; release via t.Cleanup instead, and put a watchdog on the waits so a wait that stops honoring its context fails rather than hangs. Cover keyedMutex's refcounting under contention and on abandoned waits, that a queued post still gets its whole budget, that a wait gives up with its context and is bounded without one, and the refreshed fields. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
|
Updated:
Merged current |
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Create, Approve and Restart post each workflow's status once, from start(), and a blocked pipeline posts its own round since it never gets there. When start() fails, the pipeline, its workflows and their steps have to end up in error, and that is what the forge gets. None of this was covered, so dropping any of those posts or transitions went unnoticed. The harness keeps what Create & co. persist like a store would, so the posts re-read the same state they would in production. Also say in PostWorkflowStatus what gets posted when persisting a state change failed. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
|
Merged main. The conflicts were mostly with #7516 and #7520, cancel keeps the not-started handling from #7516 and posts through Also added tests for when statuses get posted (4f8204a): once for Create, Approve and Restart, the blocked case, and start failures. None of that was covered before, so dropping any of those posts didn't fail anything. Description is updated, the ordering fix from my last comment is in there now. |
Split out of #6851 as requested. This one only has the pipeline status posting changes, the GraphQL config fetch was the other half and got merged as #7025.
Two related changes to the pipeline creation path. We run pipelines with 60+ workflows and these were where most of the time went.
1. Post per-workflow commit statuses concurrently
updatePipelineStatusposted one status per workflow, one after the other. For a pipeline with 63 workflows that alone takes tens of seconds. Statuses now go out with a concurrency of 4. That's low on purpose, forges rate limit concurrent writes from one user a lot harder than sequential ones.It also fixes the old loop stopping at the first error, which left all remaining workflows without a status. Now every workflow is attempted, failures are logged per workflow, and there's a summary line if any failed.
2. Post forge statuses only once before start
Creating a pipeline posted the full set of per-workflow statuses three times before it started (after compile, on the pending transition and again in
start()), all with the same pending state. Approve and restart did the same double posting.The pubsub events stay for the UI, but forge statuses are now posted once, in
start(). Blocked pipelines post theirs in the blocked branch since they never reachstart().On our instance (63 workflows, webhook to first workflow start) 1 + 2 took it from about 91s median to about 2s. That was measured with a concurrency of 10 and it's 4 here, so expect a bit more. Most of the win comes from dropping the two redundant rounds anyway.
Status ordering
With posts running concurrently, the same status posted from pipeline start and from an agent's Init/Done could reach the forge out of order and leave GitHub on
pendingaftersuccess. Posts of the same status now go one at a time, and each post re-reads the workflow and pipeline from the store, so whatever reaches the forge last carries the latest persisted state. A single post is capped at 30s and the wait for its turn at 2m, so one hung request can't hold up later posts forever.Failure path
A failure in
start()used to leave the pipeline pending forever, with pending commit statuses. Now the pipeline, its workflows and their steps move to error and the terminal statuses get posted, the same waydecline.godoes it.There's also a debug-level timing line per phase (hook parse, config fetch, compile, status publishing, start) to help find whatever latency is left.