fix(agent): workflow runner use shutdown context#6021
Conversation
|
@Pnkcaht for you as you are new to the project i just documented a bunch of dev stuff: -> https://woodpecker-ci-woodpecker-pr-6019.surge.sh/docs/next/development/architecture |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6021 +/- ##
==========================================
- Coverage 21.86% 21.85% -0.01%
==========================================
Files 432 432
Lines 39254 39258 +4
==========================================
Hits 8581 8581
- Misses 29865 29869 +4
Partials 808 808 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
before the patch: if you cancle the agent while running a workflow the steps and workflow is marked as failed now: workfow is correctly stated as failed but the step is marked as success |
|
@6543 What do you think? :)
|
|
sorry wont do ... the steps are marked as succes the state of the whole workflow is not the problem |
fix(agent): use shutdown context for reporting metadata Co-authored-by: 6543 <6543@obermui.de>
|
Can you explain the mistakes you made? I can fix them. |
6543
left a comment
There was a problem hiding this comment.
lgtm as smal refactor pull and handling context now correct
|
this intorduced an regression, proper fix is #6361 |

What was happening
When a workflow/run was canceled from the UI or API, the server correctly marked the run as Canceled, but the runner machines continued executing job steps.
Specifically:
This resulted in:
Related issue
Closes #5925
Related PRs
This change complements previous cancellation-related fixes:
While those PRs focus on step and backend cleanup, this PR ensures that workflow cancellation is properly propagated to the runner execution context.
What this PR changes
This PR ensures that canceling a workflow immediately stops execution on the runner.
Why this approach
In Woodpecker, the workflow context is the single source of truth for execution lifecycle.
Previously, receiving a cancel event did not reliably cancel the workflow execution context, allowing pipeline steps to continue running.
By explicitly canceling the workflow context when a cancel signal is received:
This aligns runner behavior with what the UI reports and avoids wasted resources.
Implementation overview
sequenceDiagram participant UI as Web UI / API participant Server as Woodpecker Server participant Runner as Agent Runner participant Pipeline as Pipeline Runtime participant Backend as Backend Engine UI->>Server: Cancel workflow Server->>Runner: Cancel signal (Wait) Runner->>Runner: cancel workflow context Runner->>Pipeline: ctx.Done() Pipeline->>Backend: stop execution Backend-->>Pipeline: terminate running steps Pipeline-->>Runner: execution aborted Runner->>Server: report canceled state