Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation for Task Result expression in Pipeline Results not working #4922

Closed
vsinghai opened this issue May 31, 2022 · 3 comments
Closed
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@vsinghai
Copy link
Contributor

Expected Behavior

A Pipeline's Results can be composed of one or many Task Results emitted during the Pipeline's execution variables of the form $(tasks.<task-name>.results.<result-name>). If a variable passed to Pipeline's Results does not take the expected form, the Pipeline validation should fail.

For more information, please reference this doc

Example

Modified the Pipeline in the provided example as such:

# Pipeline to clone repo into shared workspace and cleanup the workspace after done
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: clone-cleanup-workspace
spec:
  results:
    - name: initialized-1 
      value: $(tasks.check-git-commit.results.init)
    - name: initialized-2 
      value: this is static 
    - name: initialized-3
      value: $(foo.bar)
  workspaces:
    # common workspace where git repo is cloned and needs to be cleanup after done
    - name: git-source
  tasks:
    # Clone app repo to workspace
    - name: clone-app-repo
      taskRef:
        name: git-clone-from-catalog
      params:
        - name: url
          value: https://github.com/tektoncd/community.git
        - name: subdirectory
          value: application
      workspaces:
        - name: output
          workspace: git-source
    - name: check-git-commit
      params:
        - name: commit
          value: $(tasks.clone-app-repo.results.commit)
      taskSpec:
        params:
          - name: commit
            type: string
        results:
          - name: init
        steps:
          - name: check-commit-initialized
            image: alpine
            script: |
              if [[ ! $(params.commit) ]]; then
                exit 1
              fi
              printf foobar | tee /tekton/results/init
  finally:
    # Cleanup workspace
    - name: cleanup
      taskRef:
        name: cleanup-workspace
      workspaces:
        - name: source
          workspace: git-source
    - name: check-git-commit1
      params:
        - name: commit
          value: $(tasks.clone-app-repo.results.commit)
      taskSpec:
        params:
          - name: commit
            type: string
        results:
          - name: init
        steps:
          - name: check-commit-initialized
            image: alpine
            script: |
              if [[ ! $(params.commit) ]]; then
                exit 1
              fi
              printf true | tee /tekton/results/init

Actual Behavior

And this was the created PipelineRun, with the Finally Task's Result passed on to the Pipeline:

$ tkn pr describe -L
Name:              write-and-cleanup-workspace
Namespace:         test
Pipeline Ref:      clone-cleanup-workspace
Service Account:   default
Timeout:           1h0m0s
Labels:
 tekton.dev/pipeline=clone-cleanup-workspace

🌡️  Status

STARTED          DURATION     STATUS
43 seconds ago   40 seconds   Succeeded

📝 Results

 NAME              VALUE
 ∙ initialized-1   foobar
 ∙ initialized-2   this is static

📂 Workspaces

 NAME           SUB PATH   WORKSPACE BINDING
 ∙ git-source   ---        VolumeClaimTemplate

🗂  Taskruns

 NAME                                              TASK NAME           STARTED          DURATION     STATUS
 ∙ write-and-cleanup-workspace-check-git-commit1   check-git-commit1   15 seconds ago   7 seconds    Succeeded
 ∙ write-and-cleanup-workspace-cleanup             cleanup             15 seconds ago   12 seconds   Succeeded
 ∙ write-and-cleanup-workspace-check-git-commit    check-git-commit    22 seconds ago   7 seconds    Succeeded
 ∙ write-and-cleanup-workspace-clone-app-repo      clone-app-repo      43 seconds ago   21 seconds   Succeeded
  • Note that initialized-2, which is a static string, is produced as is.
  • Note that initialized-3, which is an invalid variable expression, is not produced and the pipeline does not fail.

Steps to Reproduce the Problem

  1. Modify the Pipeline in the provided example with the code pasted above
  2. Run the following commands:
  • kubectl apply -f pipelinerun-with-final-tasks.yaml
  • tkn pr describe -L

Additional Info

  • Kubernetes version:
Client Version: v1.24.1
Kustomize Version: v4.5.4
Server Version: v1.21.11-gke.1100
  • Tekton Pipeline version:
Client version: 0.23.1
Pipeline version: v0.35.0

Here is a Related Bug

@vsinghai vsinghai added the kind/bug Categorizes issue or PR as related to a bug. label May 31, 2022
@vsinghai
Copy link
Contributor Author

/assign

@vsinghai
Copy link
Contributor Author

/cc @jerop

vsinghai added a commit to vsinghai/pipeline that referenced this issue Jun 6, 2022
Prior to this commit, the validation for static strings for Task
Result expressions in Pipeline Results was not extensive.

This commit adds the case where a pipeline would be invalid if
there is no expression following the valid form
`$(tasks.<task-name>.results.<result-name>)`.

Please reference this [doc](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#emitting-results-from-a-pipeline) for more
information.

Fixes bug [tektoncd#4922](tektoncd#4922)
vsinghai added a commit to vsinghai/pipeline that referenced this issue Jun 8, 2022
Prior to this commit, the validation for static strings for Task
Result expressions in Pipeline Results was not extensive.

This commit adds the case where a pipeline would be invalid if
there is no expression following the valid form
`$(tasks.<task-name>.results.<result-name>)`.

Please reference this [doc](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#emitting-results-from-a-pipeline) for more
information.

Fixes bug [tektoncd#4922](tektoncd#4922)
tekton-robot pushed a commit that referenced this issue Jun 8, 2022
Prior to this commit, the validation for static strings for Task
Result expressions in Pipeline Results was not extensive.

This commit adds the case where a pipeline would be invalid if
there is no expression following the valid form
`$(tasks.<task-name>.results.<result-name>)`.

Please reference this [doc](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#emitting-results-from-a-pipeline) for more
information.

Fixes bug [#4922](#4922)
vsinghai added a commit to vsinghai/pipeline that referenced this issue Jun 9, 2022
Prior to this commit, the validation for invalid `Task Result` expressions
in `Pipeline` `Result`'s was not extensive.

This commit adds the case where a `Pipeline` would be invalid if there is
no expression following the valid form `$(tasks,<task-name>.results.<result-name>)`.

Please reference this [doc](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#emitting-results-from-a-pipeline) for more information.

Fixes bug [tektoncd#4922](tektoncd#4922)

/kind bug
/cc @jerop
vsinghai added a commit to vsinghai/pipeline that referenced this issue Jun 9, 2022
Prior to this commit, the validation for invalid `Task Result` expressions
in `Pipeline` `Result`'s was not extensive.

This commit adds the case where a `Pipeline` would be invalid if there is
no expression following the valid form `$(tasks,<task-name>.results.<result-name>)`.

Please reference this [doc](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#emitting-results-from-a-pipeline) for more information.

Fixes bug [tektoncd#4922](tektoncd#4922)

/kind bug
/cc @jerop
vsinghai added a commit to vsinghai/pipeline that referenced this issue Jun 9, 2022
Prior to this commit, the validation for invalid `Task Result` expressions
in `Pipeline` `Result`'s was not extensive.

This commit adds the case where a `Pipeline` would be invalid if there is
no expression following the valid form `$(tasks,<task-name>.results.<result-name>)`.

Please reference this [doc](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#emitting-results-from-a-pipeline) for more information.

Fixes bug [tektoncd#4922](tektoncd#4922)

/kind bug
/cc @jerop
tekton-robot pushed a commit that referenced this issue Jun 9, 2022
Prior to this commit, the validation for invalid `Task Result` expressions
in `Pipeline` `Result`'s was not extensive.

This commit adds the case where a `Pipeline` would be invalid if there is
no expression following the valid form `$(tasks,<task-name>.results.<result-name>)`.

Please reference this [doc](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#emitting-results-from-a-pipeline) for more information.

Fixes bug [#4922](#4922)

/kind bug
/cc @jerop
@vsinghai
Copy link
Contributor Author

vsinghai commented Jun 9, 2022

@jerop I believe this issue can be closed now.

@vsinghai vsinghai closed this as completed Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

1 participant