pipeline: Finally tasks should be triggered in case of missing results

Expected Behavior

I have a finally task that consumes results of previous tasks. The documentation states:

finally tasks are guaranteed to be executed in parallel after all PipelineTasks under tasks have completed regardless of success or error.

The task producing the result fails with a nonzero exit code. I expect that the finally task gets triggered.

Actual Behavior

Finally task is not run instead it is waiting forever for results. It is fine if the expected results are missing (and set to null). But the finally task should always be triggered.

Steps to Reproduce the Problem

  1. Apply the following definition:
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: generator-task
spec:
  results:
  - name: my_result
  steps:
  - name: make-result
    image: busybox
    script: |
      echo -n "foo" | tee $(results.my_result.path)
      exit 1
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: finally-task
spec:
  params:
  - description: value of result from previous task
    name: former_result
  steps:
  - name: use-result
    image: busybox
    script: |
        echo -n "$(params.former_result)"

---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: resulttest
spec:
  finally:
  - name: notification
    params:
    - name: former_result
      value: $(tasks.generator.results.my_result)
    taskRef:
      name: finally-task      
  tasks:
  - name: generator
    taskRef:
      name: generator-task
  1. Create a PipelineRun for pipeline resulttest
  2. The finally task for this pipeline never gets executed.

Additional Info

There is a related section in the documentation about results after error but this is not helpful. Setting onError: continue completely hides the error which is not what I want.

Not sure but may be related to TEP-0058. Potentially another use case to be covered?

  • Kubernetes version:

    Output of kubectl version:

    Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", 
    GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:38:26Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"darwin/amd64"}
    Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.6", GitCommit:"d921bc6d1810da51177fbd0ed61dc811c5228097", GitTreeState:"clean", BuildDate:"2021-10-27T17:44:26Z", GoVersion:"go1.16.9", 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.17.0 Pipeline version: v0.28.2 Dashboard version: v0.21.0

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 6
  • Comments: 23 (7 by maintainers)

Most upvoted comments

Still exists on latest pipeline release: v0.44.0

Thanks for sharing the proposal. I understand that it may be designed like this but I consider this not to be very practical. I assume in many cases finally tasks are used to e.g. send notifications about build status etc. In case something fails (and thus a result may be missing) you always want to get the notification and not a silent death… So hope to see the enhancements soon 😃

And one more comment: You at least should adapt the documentation (see citation above). The statement that “finally tasks are guaranteed to be executed regardless of of success or error” is wrong if this is by design.

This is still incredibly important, and if I am being honest this sort of thing is why I have moved on from tekton.

Yep, Thanks! For right now I upload everything at the end of each TaskRun and pull it back down in the Finally (well, I was already uploading anyways, I just was hoping to use /results to save some calls and task params).

It works, but it would save some complexity to be able to just poll the /results.