pipeline icon indicating copy to clipboard operation
pipeline copied to clipboard

task results not replaced with their values in childReferences

Open pritidesai opened this issue 2 years ago • 6 comments

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

  1. Deploy Tekton Pipelines with the latest commit
  2. Enable alpha feature flag
kubectl patch cm/feature-flags -p "{\"data\":{\"enable-api-fields\":\"alpha\"}}" -n tekton-pipelines
  1. 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"
  1. 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 or kubectl 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

pritidesai avatar Jan 31 '23 21:01 pritidesai

is this also part of tep-75&76 promotion?

Yongxuanzhang avatar Feb 06 '23 18:02 Yongxuanzhang

This seems to be a bug before tep 75&76, but worth investigating

Yongxuanzhang avatar Feb 06 '23 21:02 Yongxuanzhang

@pritidesai Just to confirm, is it expected for when conditions to be included in childReferences ?

afrittoli avatar Feb 06 '23 21:02 afrittoli

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 avatar Feb 06 '23 21:02 pritidesai

@pritidesai Just to confirm, is it expected for when conditions to be included in childReferences ?

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.

pritidesai avatar Feb 06 '23 22:02 pritidesai

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?

chengjoey avatar Feb 08 '23 16:02 chengjoey

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.

tekton-robot avatar May 09 '23 16:05 tekton-robot

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.

tekton-robot avatar Jun 08 '23 16:06 tekton-robot

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 avatar Jul 08 '23 17:07 tekton-robot

@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.

tekton-robot avatar Jul 08 '23 17:07 tekton-robot

/reopen /lifecycle frozen

jerop avatar Sep 20 '23 15:09 jerop

@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.

tekton-robot avatar Sep 20 '23 15:09 tekton-robot