Repository navigation
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 no record for this UID).
|
@gmeghnag: This pull request references SRVKP-15665 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.1.0" version, but no target version was set. 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. |
|
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. |
|
[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 |
|
/ok-to-test |
|
@gmeghnag: Cannot trigger testing until a trusted user reviews the PR and leaves an 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 kubernetes-sigs/prow repository. |
PR Reviewer Guide 🔍Warning
Here are some key observations to aid the review process:
|
|
Important The |
A TaskRun is not always labelled with the UID of the PipelineRun being displayed: on a multi-cluster setup the PipelineRun exists on the hub and on the spoke with different UIDs (see the uniqBy by name in useTaskRuns), and TaskRuns created by older Tekton versions carry no tekton.dev/pipelineRunUID label at all. Returning no TaskRun for those would leave the task without its real status, so keep the fallback and cover it with a test.
|
Hi @gmeghnag |
|
/agentic_review |
Code Review by Qodo
1.
|
Revert passing the PipelineRun UID to `useTaskRuns()` from `PipelineRunVisualization`: the UID becomes a required term of both the k8s selector and the Tekton Results filter (`selectorToFilter` turns every matchLabel into a mandatory `EQ`), which would drop TaskRuns whose `tekton.dev/pipelineRunUID` label does not match the displayed PipelineRun - the case of a Kueue-managed hub PipelineRun, whose TaskRuns carry the spoke UID. Picking the current TaskRun in `getTaskRunForPipelineTask` already fixes the stale-record status, and it keeps working on the broader, name-only list. The Results query stays filtered by `tekton.dev/pipelineRun` only, so it can return the records of earlier runs that reused the name; that is accepted in exchange for not filtering out TaskRuns that legitimately carry another UID.
|
Hi @anwesha-palit-redhat, thanks for the review. #1489, #1490 and #1491 are closed, we'll The trade-off: the Results query stays name-only, so it still returns the records of earlier runs that reused the name. Their status is no longer displayed, but the extra records remain. On old Tekton, Tell me what the multi-cluster and pipeline-in-pipeline runs show and I'll rework as needed. |
There was a problem hiding this comment.
Not sure if adding a new method is the best way to address this.
IMO, the root cause is that PipelineRunVisualization (Overview topology) calls useTaskRuns with only the PipelineRun name. This results in the following Tekton Results CEL filter:
data.metadata.labels["tekton.dev/pipelineRun"] == "repro-run"This fetches all historical TaskRuns associated with that PipelineRun name. Merging this data can cause the topology to show a failure (0/1, pf-m-danger) even when the current TaskRun succeeded.
TaskRunsList already passes parentUid (SRVKP-7409), which adds tekton.dev/pipelineRunUID to the selector and scopes the Results query to the correct PipelineRun instance.
We could try the same approach in src/components/pipelineRuns-details/PipelineRunVisualization.tsx.
Currently:
useTaskRuns(
pipelineRun?.metadata?.namespace,
pipelineRun?.metadata?.name,
undefined,
undefined,
{
pipelineRunFinished,
pipelineRunManagedBy: pipelineRun?.spec?.managedBy,
},
);Proposed change:
const [taskRuns, k8sLoaded, trLoaded, , pendingAdmission, proxyUnavailable] =
useTaskRuns(
pipelineRun?.metadata?.namespace,
pipelineRun?.metadata?.name,
undefined,
pipelineRun?.metadata?.uid,
{
pipelineRunFinished,
pipelineRunManagedBy: pipelineRun?.spec?.managedBy,
},
);Can we try this once please ?


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:
tekton.dev/pipelineRun=<name>only, so it also returned the records of previously deleted runs that used the same name (the merge inuseTaskRunsde-duplicates bymetadata.uid, so both records survive).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.What this PR changes is cause 2: a new helper
getTaskRunForPipelineTask(taskRuns, taskName, pipelineRunUid)prefers the TaskRun whosetekton.dev/pipelineRunUIDlabel matches the displayed PipelineRun, and falls back to the first task-name match.Cause 1 is deliberately not addressed by narrowing the query. An earlier revision of this PR passed the PipelineRun UID to
useTaskRuns(); that was dropped for the reason below.Why the UID is not pushed into the query
The UID argument does not merely rank results, it becomes a required term of both the k8s selector and the Tekton Results filter:
selectorToFilter()→labelsToFilter()conjuncts every matchLabel into anEQ. Any TaskRun whosetekton.dev/pipelineRunUIDlabel does not equal the displayed PipelineRun's UID is then dropped before it can reachgetTaskRunForPipelineTask. That is the situation of a Kueue-managed hub PipelineRun, whose TaskRuns carry the spoke UID (useTaskRunsde-duplicates hub and spoke PipelineRuns by name precisely because their UIDs differ).Selection in the helper fixes the displayed status on the broader, name-only list, without excluding anything.
Accepted trade-off: the Results query still returns the records of earlier runs that reused the name (widening fetched bytes, and beyond ~50 stale records a page may not contain the desired one). If that ever matters, a filter accepting both
pipelineRunUID == <uid>and a missing/foreign UID would be the follow-up — out of scope here.Testing
src/components/utils/__tests__/pipeline-utils.spec.ts:Test Suites: 65 passed, 65 total; Tests: 1 skipped, 762 passed, 763 total.npx eslintclean on the 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 built from an earlier revision of this branch — the one that also passed the UID to
useTaskRuns(). The status shown comes fromgetTaskRunForPipelineTask, which is unchanged in the final revision; what differs is only the width of the Results query (narrow in the tested image, name-only here). The values below therefore hold for the fix as proposed, with one difference, stated so it is not mistaken for a measurement of the final code: the Results request in the tested image carried the extrapipelineRunUIDterm, and here it does not..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); the status fix does not depend on thatBefore (task node red,
0/1, while the TaskRun isTrue Succeeded):After (no
pf-m-dangernode, step badge1/1):Notes
master; the same fix is needed onrelease-v1.25.x,release-v1.24.x,release-v1.23.xandrelease-v1.22.x. Those branches (and theiruseTaskRuns()signature, which takespipelineRunUidin the options object rather than as the 4th positional argument) differ, so they need separate patches — happy to send them.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.