pipeline icon indicating copy to clipboard operation
pipeline copied to clipboard

Finally tasks not triggered in case of task failing due to missing results

Open ppitonak opened this issue 1 year ago • 19 comments

Expected Behavior

I have a pipeline with two tasks - first one producing a result, second one using the result and finally task not using the result at all. Finally task should always run.

Actual Behavior

When first task doesn't produce the result, second one correctly fails. Finally task is skipped.

Steps to Reproduce the Problem

  1. Run the below pipeline
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: finally-pipeline
spec:
  tasks:
  - name: task-a
    taskSpec:
      steps:
      - name: hello
        image: registry.access.redhat.com/ubi8/ubi-minimal
        script: |
          #!/usr/bin/env bash
          echo "Hello from task A"
          # uncomment to fix the issue
          #echo "foo" > $(results.foo.path)
          sleep 5
      results:
        - name: foo
  - name: task-b
    params:
      - name: input
        value: $(tasks.task-a.results.foo)
    taskSpec:
      params:
        - name: input
      steps:
      - name: hello
        image: registry.access.redhat.com/ubi8/ubi-minimal
        script: |
          #!/usr/bin/env bash
          echo "Hello from task B"
          echo "Content of param: $(params.input)"
          sleep 5
  finally:
  - name: final-task
    taskSpec:
      steps:
      - name: finally
        image: registry.access.redhat.com/ubi8/ubi-minimal
        script: |
          #!/usr/bin/env bash
          echo "Hello from finally"
          sleep 5

Additional Info

  • Kubernetes version:

    Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.9", GitCommit:"d1483fdf7a0578c83523bc1e2212a606a44fd71d", GitTreeState:"archive", BuildDate:"2023-09-16T00:00:00Z", GoVersion:"go1.20.8", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.9+636f2be", GitCommit:"e782f8ba0e57d260867ea108b671c94844780ef2", GitTreeState:"clean", BuildDate:"2023-10-20T19:28:29Z", GoVersion:"go1.19.13 X:strictfipsruntime", Compiler:"gc", Platform:"linux/arm64"}
  • 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.32.2
Chains version: v0.17.1
Pipeline version: v0.50.3
Triggers version: v0.25.2
Operator version: v0.68.1

Similar to https://github.com/tektoncd/pipeline/issues/4438

ppitonak avatar Nov 03 '23 16:11 ppitonak

Thanks! I will take a look

Yongxuanzhang avatar Dec 06 '23 22:12 Yongxuanzhang

/assign

Yongxuanzhang avatar Dec 19 '23 19:12 Yongxuanzhang

I think this is caused by this pr https://github.com/tektoncd/pipeline/pull/6792

Yongxuanzhang avatar Dec 19 '23 19:12 Yongxuanzhang

using tekton v0.54.0.

Same issue. In my case failed task had no image digest pushed in the result, because the build failed. Pipelinerun finished on the build-buildpack task.

buildpack-pipeline-build-buildpack-pod   0/3     Init:0/3            0          2s
buildpack-pipeline-build-buildpack-pod   0/3     Init:1/3            0          3s
buildpack-pipeline-build-buildpack-pod   0/3     Init:2/3            0          4s
buildpack-pipeline-build-buildpack-pod   0/3     PodInitializing     0          5s
buildpack-pipeline-build-buildpack-pod   3/3     Running             0          6s
buildpack-pipeline-build-buildpack-pod   3/3     Running             0          6s
buildpack-pipeline-build-buildpack-pod   2/3     NotReady            0          8s
buildpack-pipeline-build-buildpack-pod   0/3     Error               0          46s
affinity-assistant-a5f6edee78-0          1/1     Terminating         0          65s
affinity-assistant-a5f6edee78-0          0/1     Terminating         0          66s
affinity-assistant-a5f6edee78-0          0/1     Terminating         0          66s
affinity-assistant-a5f6edee78-0          0/1     Terminating         0          66s
affinity-assistant-a5f6edee78-0          0/1     Terminating         0          66s
buildpack-pipeline-build-buildpack-pod   0/3     Error               0          47s
buildpack-pipeline-build-buildpack-pod   0/3     Error               0          48s

output of the build-buildpack task:

[build-buildpack : build] Adding label 'org.opencontainers.image.source'
[build-buildpack : build] Adding label 'org.opencontainers.image.vendor'
[build-buildpack : build] Adding label 'org.opencontainers.image.version'
[build-buildpack : build] Setting default process type 'web'
[build-buildpack : build] Saving 11111111.dkr.ecr.us-east-1.amazonaws.com/project/prod/backend:fca18e...
[build-buildpack : build] *** Images (sha256:3a8aac28491b40f6709be20995013ec4dd2647643ec51d7116b54424326f4d01):
[build-buildpack : build]       11111111.dkr.ecr.us-east-1.amazonaws.com/project/prod/backend:fca18e - PUT https://11111111.dkr.ecr.us-east-1.amazonaws.com/v2/project/prod/backend/manifests/fca18e: TAG_INVALID: The image tag 'fca18e' already exists in the 'project/prod/backend' repository and cannot be overwritten because the repository is immutable.
[build-buildpack : build] ERROR: failed to export: failed to write image to the following tags: [11111111.dkr.ecr.us-east-1.amazonaws.com/project/prod/backend:fca18e: PUT https://11111111.dkr.ecr.us-east-1.amazonaws.com/v2/project/prod/backend/manifests/fca18e: TAG_INVALID: The image tag 'fca18e' already exists in the 'project/prod/backend' repository and cannot be overwritten because the repository is immutable.]

[build-buildpack : results] 2023/12/29 01:29:14 Skipping step because a previous step failed

the final task is not executed

  finally:
    # ┌─────────────────────────────────────────────────────────────────────
    # │ ⚫ Final Notify                                                     
    # └─────────────────────────────────────────────────────────────────────
    - name: notify
      displayName: "Notification from $(context.pipeline.name)"
      when:
        - input: $(params.workflow.notify)
          operator: in
          values: ['true']
      taskRef:
        name: notify
      workspaces:
        - name: source
          workspace: source
      params:
        - name:  working_directory
          value: $(params.git.checkout_directory)
        - name:  environment
          value: $(params.environment)
        - name:  application
          value:
            project:           $(params.application.project)
            component:         $(params.application.component)
            url:               $(params.application.url)
            argocd_app:        $(params.application.argocd_app)
            argocd_url:        $(params.application.argocd_url)
            tekton_url:        $(params.application.tekton_url)
            jira_url:          $(params.application.jira_url)
            jira_prefix:       $(params.application.jira_prefix)
            grafana_url:       $(params.application.grafana_url)
            karma_url:         $(params.application.karma_url)
            alertmanager_url:  $(params.application.alertmanager_url)
            sentry_url:        $(params.application.sentry_url)
            documentation_url: $(params.application.documentation_url)
            devops_team:       $(params.application.devops_team)
            pm_team:           $(params.application.pm_team)
            tm_team:           $(params.application.tm_team)
            lead_developers:   $(params.application.lead_developers)
        - name:  git
          value:
            repository_url:      $(params.git.repository_url)
            checkout_branch:     $(params.git.checkout_branch)
            checkout_revision:   $(params.git.checkout_revision)
            commit_author:       $(params.git.commit_author)
            commit_author_url:   $(params.git.commit_author_url)
            commit_message:      $(params.git.commit_message)
        - name:  status
          value: $(tasks.status)
        - name:  pipelinerun
          value:
            name:      $(context.pipelineRun.name)
            namespace: $(context.pipelineRun.namespace)
            uid:       $(context.pipelineRun.uid)
        - name: image_digest
          value: $(tasks.build-$(params.build.use).results.app_image_digest)

dmitry-mightydevops avatar Dec 29 '23 01:12 dmitry-mightydevops

Thanks! Just come back from holidays, will work on this issue

Yongxuanzhang avatar Jan 02 '24 19:01 Yongxuanzhang

@Yongxuanzhang any updates?

dmitry-mightydevops avatar Jan 16 '24 17:01 dmitry-mightydevops

@Yongxuanzhang any updates?

Sorry I'm kinda busy recently, 😢 , don't have enough time to come up with a solution yet.

Yongxuanzhang avatar Jan 16 '24 21:01 Yongxuanzhang

Is there any chance that anybody would work on this?

ppitonak avatar Apr 23 '24 14:04 ppitonak

@Yongxuanzhang If you are not working, shall I assign this issue to myself?

divyansh42 avatar May 21 '24 15:05 divyansh42

@Yongxuanzhang is on leave for now so please go ahead @divyansh42. I don't think he will mind 😄

chitrangpatel avatar May 21 '24 16:05 chitrangpatel

Does anybody plan to work on this?

ppitonak avatar Aug 09 '24 07:08 ppitonak

/assign I will work on this

divyansh42 avatar Aug 09 '24 07:08 divyansh42