Repository navigation
SRVKP-15665: Fix PipelineRun task shown as failed because of a stale TaskRun record - #1491
Conversation
The PipelineRun topology merges the TaskRuns of the run from the Kubernetes API and from Tekton Results. The Results query of the topology was filtered by the `tekton.dev/pipelineRun` label only, so the TaskRun records left in Results by an earlier PipelineRun that used the same name came back too, and `appendPipelineRunStatus()` picked the first match by the `tekton.dev/pipelineTask` label - possibly the stale one. The task then rendered as failed (`pf-m-danger`, `0/1`) although the current TaskRun succeeded. - `PipelineRunVisualization` now passes the PipelineRun UID to `useTaskRuns()`, so the Results query is narrowed to `tekton.dev/pipelineRunUID` as well. - `getTaskRunForPipelineTask()` selects the TaskRun whose `tekton.dev/pipelineRunUID` label matches the displayed PipelineRun, and falls back to the first task-name match when the label is absent (TaskRuns created by older Tekton versions, or the hub/spoke UID mismatch of a multi-cluster setup).
|
@gmeghnag: This pull request references SRVKP-15665 which is a valid jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gmeghnag 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 |
|
Hi @gmeghnag. Thanks for your PR. I'm waiting for a openshift-pipelines member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
PR Reviewer Guide 🔍Warning
Here are some key observations to aid the review process:
|
|
Important The |
|
Closing as requested: release branches are handled with the |


Type of Change
Summary
The PipelineRun topology shows a task as failed (red icon,
pf-m-danger, step badge0/1) even when the TaskRun of the current PipelineRun succeeded. It happens when a PipelineRun is created with the name of a previously deleted PipelineRun and Tekton Results still holds that run's TaskRun record.Jira: SRVKP-15665
Two root causes, both fixed here:
PipelineRunVisualization.tsxcalleduseTaskRuns()without thepipelineRunUidargument, so the Tekton Results query filtered ontekton.dev/pipelineRun=<name>only and returned the records of the deleted run as well (the merge inuseTaskRunsde-duplicates bymetadata.uid, so both records survive). The UID is now passed, so the query is narrowed totekton.dev/pipelineRunUIDtoo.appendPipelineRunStatus()inpipeline-utils.tstook the task status with_.find()on thetekton.dev/pipelineTasklabel — the first match of the merged list, which could be the stale record. A new helpergetTaskRunForPipelineTask(taskRuns, taskName, pipelineRunUid)prefers the TaskRun whosetekton.dev/pipelineRunUIDlabel matches the displayed PipelineRun, and falls back to the previous behaviour (first task-name match) when that label is absent, as with TaskRuns created by older Tekton versions.The change is deliberately conservative: only the topology call site is narrowed, and status derivation stays correct even if a wider TaskRun list is passed in from elsewhere.
Testing
src/components/utils/__tests__/pipeline-utils.spec.ts:Test Suites: 4 failed, 1 skipped, 44 passed, 48 of 49 total; Tests: 12 skipped, 560 passed, 572 total. The 4 red suites (pipeline-topology/__tests__/utils,WhenExpressionDecorator,topology/build-decorators/__tests__/PipelineRunDecorator,pipelines-details/__tests__/PipelineVisualization) fail identically on the unmodified branch - verified on a fresh clone of it - so they are pre-existing and unrelated to this change.npx eslintclean on the three touched files;npx tsc --noEmitclean.Screen Recording / Screenshot
Reproducer: https://github.com/gmeghnag/stale-taskrun-repro — a task that fails (run #1), the PipelineRun is deleted, then a PipelineRun with the same name is created and succeeds (run #2).
Verified end-to-end on OCP 4.19.51 with OpenShift Pipelines 1.24.3 (Tekton Results enabled) using a custom plugin image carrying the same change, built from the PatternFly 5 tree — which is the code the operator ships for that release. On this branch the change is identical (same helper, same call site, same tests) and is covered by the unit tests above.
.pf-m-dangernodes in the topology.pf-m-successnodes0/11/1Succeeded(while the node is red)Succeededlabels["tekton.dev/pipelineRun"]=="repro-run"(4 records)labels["tekton.dev/pipelineRunUID"]=="eb827fe6-…"(1 record)Before (task node red,
0/1, while the TaskRun isTrue Succeeded):After (no
pf-m-dangernode, step badge1/1):Notes
master(SRVKP-15665: Fix PipelineRun task shown as failed because of a stale TaskRun record #1488),release-v1.25.xandrelease-v1.24.x.useTaskRuns()without the UID (PipelineRunLogs.tsx,PipelineRunCustomDetails.tsx,PipelineRunStatusPopoverContent.tsx,PipelineRunItem.tsx,useLinkedPipelineRunTaskStatus.tsx). They do not derive a wrong status any more thanks togetTaskRunForPipelineTask, but their Results query remains name-wide; narrowing them can be a follow-up.