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

Finally task is skipped when dependent on results from a failed task #4118

Closed
joshfrench opened this issue Jul 26, 2021 · 4 comments
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@joshfrench
Copy link

Expected Behavior

According to the docs: "Final tasks are guaranteed to be executed in parallel after all PipelineTasks under tasks have completed regardless of success or error."

Actual Behavior

If a final task references the result of a task which exited with an error, that final task is skipped.

Steps to Reproduce the Problem

Run a pipeline with:

  1. A failing task
  2. A final task that depends on a result from the above
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  generateName: test-finally-
  namespace: default
spec:
  pipelineSpec:
    tasks:
      - name: fail
        taskSpec:
          results:
            - name: missing
          steps:
            - name: fail
              image: alpine:latest
              script: exit 1
    finally:
      - name: final
        params:
          - name: required
            value: $(tasks.fail.results.missing)
        taskSpec:
          params:
            - name: required
              default: 'ok'
          steps:
            - name: final
              image: alpine:latest
              command: ["echo"]
              args: ["$(params.required)"]

Inspect the run to see the skipped final task:

% tkn pr describe test-finally-xxxxx
Tasks Completed: 1 (Failed: 1, Cancelled 0), Skipped: 1 ("step-fail" exited with code 1 (image: "docker-pullable://alpine@sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0")

...

Skipped Tasks

 NAME
 ∙ final

Removing the final task's input param and using the default value instead makes the final task run as expected.

Writing something to $(results.missing.path) before exiting with an error does not change the behavior; a non-zero exit code seems to be sufficient to trigger this.

Additional Info

  • Kubernetes version:
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-12T14:11:29Z", GoVersion:"go1.16.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.16-eks-7737de", GitCommit:"7737de131e58a68dda49cdd0ad821b4cb3665ae8", GitTreeState:"clean", BuildDate:"2021-03-10T21:33:25Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
  • Tekton Pipeline version:

I first discovered this on v0.23.0 but it affects the most recent version as well:

Client version: 0.18.0
Pipeline version: v0.26.0
Triggers version: v0.13.0
Dashboard version: v0.17.0
@joshfrench joshfrench added the kind/bug Categorizes issue or PR as related to a bug. label Jul 26, 2021
@pritidesai
Copy link
Member

pritidesai commented Jul 27, 2021

hey @joshfrench, when a task exits with an error, the results are not added to the status. The results are only initialized with a successful task. @afrittoli has requested a result (or something similar) to be made available even when a task fails with error, see issue #3749.

Also, if you have a use case where you would like to continue after a step error and also have the result initialized before exiting with 1, we have a proposal to introduce a feature to ignore step error https://github.com/tektoncd/community/blob/main/teps/0040-ignore-step-errors.md. The implementation PR is open as well. You can refer to the example demonstrating the results with the failed steps here.

@joshfrench
Copy link
Author

Thanks @pritidesai, that's helpful context. Until one of those features is merged, is wrapping a step with exit 0 how the community typically works around this?

@pritidesai
Copy link
Member

pritidesai commented Jul 27, 2021

is wrapping a step with exit 0 how the community typically works around this?

That is correct, its a workaround until we have issue #3749 fixed and/or PR #4106 merged.

@joshfrench
Copy link
Author

Thanks! Looking forward to those changes.

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

2 participants