Repository navigation
fix: preserve PipelineRun-owned TaskRuns during history pruning - #424
yuzichen12123 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #424 +/- ##
==========================================
+ Coverage 50.40% 50.56% +0.16%
==========================================
Files 19 19
Lines 2113 2120 +7
==========================================
+ Hits 1065 1072 +7
Misses 916 916
Partials 132 132
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| // isPipelineRunOwned reports whether a resource belongs to a PipelineRun and | ||
| // therefore must be reclaimed with its parent instead of by history limiting. | ||
| func isPipelineRunOwned(resource metav1.Object) bool { |
There was a problem hiding this comment.
Thanks for the fix @yuzichen12123!
One nit: Could we have used this fucntion instead of creating another one with similar logic ?
There was a problem hiding this comment.
Thanks for the suggestion. isStandaloneTaskRun is defined in pkg/reconciler/taskrun, while the history limiter is implemented in pkg/config. The taskrun package already imports config, so having config call back into taskrun would create an import cycle.
The existing helper is also unexported and TaskRun-specific, whereas the history limiter is shared by TaskRuns and PipelineRuns. The current implementation therefore keeps the ownership check in pkg/config while preserving the same label and ownerReference logic. We can extract a shared helper into a common package in a follow-up refactor if needed.
There was a problem hiding this comment.
Yeah lets put shared function in pkg/config/helper.go, that's a small change I believe and keeps the ownership logic in one place. Thoughts on just including it here vs follow-up? either way works, but since we're already touching this area, so we can do it in this PR itself.
There was a problem hiding this comment.
Thanks @infernus01, agreed. I've included this refactor in the PR in c4dac9f.
The ownership check now lives in pkg/config/helper.go as IsPipelineRunOwned, shared by the history limiter and the standalone TaskRun check. isStandaloneTaskRun delegates to the shared helper, keeping both the label and ownerReference checks in one place without introducing an import cycle.
I've added table-driven coverage for the ownership signals, empty labels, and unrelated or mixed ownerReferences, and kept the original history-pruning regression test. make test-unit (including the race detector), go vet ./..., and lint checks pass locally. The new PR CI is queued.
Centralize label and ownerReference detection in config.IsPipelineRunOwned so history limiting and standalone TaskRun checks use the same logic. Cover both ownership signals, empty labels, and unrelated or mixed owners. Signed-off-by: Zichen Yu <1062955096@qq.com> Assisted-by: GPT-6 (via Codex)
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary
History-limit cleanup can delete completed TaskRuns that belong to a still-running PipelineRun. The PipelineRun controller then treats those tasks as unscheduled and recreates them, causing completed pipeline work to run again.
This change excludes PipelineRun-owned resources from the history-limiter candidate set. It recognizes both ownership signals used by Tekton:
tekton.dev/pipelineRunlabel;PipelineRunownerReference.The ownerReference check protects resources that do not carry the label.
Fixes #381
Testing
go test ./...The regression test verifies that history pruning removes eligible standalone resources while preserving PipelineRun children identified by either ownership mechanism.