You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "danielemoraschi (via GitHub)" <gi...@apache.org> on 2026/04/13 09:00:08 UTC
[PR] Fix/8787 cancel pipeline keeps running [incubator-devlake]
danielemoraschi opened a new pull request, #8832:
URL: https://github.com/apache/incubator-devlake/pull/8832
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
### ⚠️ Pre Checklist
> Please complete _ALL_ items in this checklist, and remove before submitting
- [x] I have read through the [Contributing Documentation](https://devlake.apache.org/community/).
- [x] I have added relevant tests.
- [x] I have added relevant documentation.
- [x] I will add labels to the PR, such as `pr-type/bug-fix`, `pr-type/feature-development`, etc.
<!--
Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes.
Please fill out as many sections below as possible.
-->
### Summary
Clicking the cancel button in the UI (which fires DELETE /api/pipelines/:id) always returns "Operation successfully completed" (HTTP 200), but the pipeline continues running. Observable for 30+ minutes after the cancel request before it stops on its own.
Three independent bugs were causing this:
1. **`CancelPipeline` silently discarded errors from `CancelTask`** (`pipeline.go`). The cancel-func was never invoked for running tasks, and pending tasks were not batch-updated in the DB. Fixed by classifying tasks into running vs pending, then delegating to `cancelRunningTasks` (triggers context cancellation) and `cancelPendingTasksInDB` (batch DB update with status guard).
2. **`gitextractor` ignored context cancellation in `storeRepoSnapshot`** (`repo_gogit.go`). `gogit.Blame()` has no context parameter, so once a blame started it ran to completion. Added `select { case <-ctx.Done() }` checks at the top of the outer commit loop and inner `patch.Stats()` loop so cancellation is respected between iterations.
3. **Cancelled tasks were recorded as `TASK_FAILED`** (`run_task.go`, `pipeline_runner.go`). The deferred status-update block didn't distinguish cancellation from failure. Now detects cancellation via `errors.Is(err, context.Canceled) || ctx.Err() == context.Canceled`, sets status to `TASK_CANCELLED`, and skips writing `failed_sub_task`. `ComputePipelineStatus` also now returns `TASK_CANCELLED` when the pipeline was cancelled, taking priority over other statuses.
Additional correctness improvements:
- `cancelPendingTasksInDB` includes `TASK_RESUME` in the status filter so tasks awaiting restart recovery are also cancelled
- `cancelRunningTasks` uses `err.GetType() == errors.NotFound` instead of `.As(errors.NotFound)` to avoid walking the entire error chain
- `SkipOnFail` guard in `run_task.go` reuses the `isCancelled` variable instead of recomputing
### Does this close any open issues?
Closes #8787
### Screenshots
N/A
### Other Information
Additional improvements:
- `cancelPendingTasksInDB` includes `TASK_RESUME` in the status filter so tasks awaiting restart recovery are also cancelled
- `cancelRunningTasks` uses `err.GetType() == errors.NotFound` instead of `.As(errors.NotFound)` to avoid walking the entire error chain
- `SkipOnFail` guard in `run_task.go` reuses the `isCancelled` variable instead of recomputing
Tests:
- Added cancellation tests to `TestComputePipelineStatus` verifies `TASK_CANCELLED` is returned when `isCancelled=true`, regardless of individual task statuses
- Added `TestCancelPipeline` with 3 subtests: cancels all pending tasks, leaves completed tasks unchanged, returns error for non-existent pipeline
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix/8787 cancel pipeline keeps running [incubator-devlake]
Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh merged PR #8832:
URL: https://github.com/apache/incubator-devlake/pull/8832
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org