pipeline
pipeline copied to clipboard
task results not replaced with their values in childReferences
Expected Behavior
As a user, I expect the pipelineRun
status to include the results in place of a task result reference. This helps diagnose the pipeline run using its status.
Actual Behavior
pipelineRun.status.childReferences
does not replace a task result when referred in when
expressions using "$(tasks.task1.results.string-result)"
or "$(tasks.task1.results.array-results[1])"
.
Steps to Reproduce the Problem
- Deploy Tekton Pipelines with the latest commit
- Enable
alpha
feature flag
kubectl patch cm/feature-flags -p "{\"data\":{\"enable-api-fields\":\"alpha\"}}" -n tekton-pipelines
- Apply pipelineRun to the cluster.
kubectl create -f pipeline-with-when-expressions-using-array-results.yaml
pipelinerun.tekton.dev/pipelinerun-with-when-expressions-using-array-results-dcghl created
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: pipelinerun-with-when-expressions-using-array-results-
spec:
pipelineSpec:
tasks:
- name: task1
taskSpec:
results:
- name: array-results
type: array
description: The array results
- name: string-result
type: string
description: The string results
steps:
- name: write-array
image: bash:latest
script: |
#!/usr/bin/env bash
echo -n "[\"1\", \"2\", \"3\"]" | tee $(results.array-results.path)
echo -n "1" | tee $(results.string-result.path)
- name: task2
when:
- input: "$(tasks.task1.results.array-results[1])"
operator: in
values: ["2"]
- input: "$(tasks.task1.results.string-result)"
operator: in
values: ["1"]
taskSpec:
steps:
- name: say-hi
image: bash:latest
script: |
echo "hi"
- Check pipelineRun status:
kubectl get pr pipelinerun-with-when-expressions-using-array-results-w74qq -o json | jq .status.childReferences
[
{
"apiVersion": "tekton.dev/v1beta1",
"kind": "TaskRun",
"name": "pipelinerun-with-when-exp9fe3c5278f6960248e739a1c08e9e593-task1",
"pipelineTaskName": "task1"
},
{
"apiVersion": "tekton.dev/v1beta1",
"kind": "TaskRun",
"name": "pipelinerun-with-when-exp9fe3c5278f6960248e739a1c08e9e593-task2",
"pipelineTaskName": "task2",
"whenExpressions": [
{
"input": "$(tasks.task1.results.array-results[1])",
"operator": "in",
"values": [
"2"
]
},
{
"input": "$(tasks.task1.results.string-result)",
"operator": "in",
"values": [
"1"
]
}
]
}
]
Additional Info
-
Kubernetes version:
Output of
kubectl version
:
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.14", GitCommit:"3321ffc07d2f046afdf613796f9032f4460de093", GitTreeState:"clean", BuildDate:"2022-11-09T13:40:19Z", GoVersion:"go1.17.13", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.0", GitCommit:"ab69524f795c42094a6630298ff53f3c3ebab7f4", GitTreeState:"clean", BuildDate:"2021-12-07T18:09:57Z", GoVersion:"go1.17.3", Compiler:"gc", Platform:"linux/amd64"}
-
Tekton Pipeline version:
Output of
tkn version
orkubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'
Client version: 0.23.1
Pipeline version: v0.43.0
is this also part of tep-75&76 promotion?
This seems to be a bug before tep 75&76, but worth investigating
@pritidesai Just to confirm, is it expected for when
conditions to be included in childReferences
?
is this also part of tep-75&76 promotion?
Hey @Yongxuanzhang this is not blocking TEP-0075 and TEP-0076 promotion, sorry for the confusion. Like its mentioned in the description, the values are not replaced even for the results which are of type string
.
@pritidesai Just to confirm, is it expected for
when
conditions to be included inchildReferences
?
Thanks @afrittoli, yes when
expressions are part of the childReferences
:
https://github.com/tektoncd/pipeline/blob/bd6a12fb6f3f95d5435b688a46d1b66f50f063c5/pkg/apis/pipeline/v1beta1/pipelinerun_types.go#L401:L413
It's valuable for the user to have this information as part of the pipelineRun status
because when
expression is a pipeline component and associated with a pipelineTask
. That's the reason, ChildReferences
is defined to have a name of the taskRun
, name of the pipelineTask
, and the when
expressions.
At present, only when the tasks are in NextSchedulableTask
, the reference values in whenexpressions will be replaced, so should the completed tasks be replaced before GetChildReferences
?
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen
with a justification.
/lifecycle stale
Send feedback to tektoncd/plumbing.
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten
with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close
with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen
with a justification.
/lifecycle rotten
Send feedback to tektoncd/plumbing.
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen
with a justification.
Mark the issue as fresh with /remove-lifecycle rotten
with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen
with a justification.
/close
Send feedback to tektoncd/plumbing.
@tekton-robot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity. Reopen the issue with
/reopen
with a justification. Mark the issue as fresh with/remove-lifecycle rotten
with a justification. If this issue should be exempted, mark the issue as frozen with/lifecycle frozen
with a justification./close
Send feedback to tektoncd/plumbing.
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/test-infra repository.
/reopen /lifecycle frozen
@jerop: Reopened this issue.
In response to this:
/reopen /lifecycle frozen
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/test-infra repository.