From 7141d2771d710382230da3ab3015d4e8e6469e19 Mon Sep 17 00:00:00 2001 From: Priti Desai Date: Thu, 7 Jan 2021 12:11:38 -0800 Subject: [PATCH] tep to capture step exit code Proposing a tep to capture step exit code and provide an option to continue after capturing the non zero exit code. Also document the container termination state to access it after the pipeline exectution finishes. --- teps/0040-capture-step-exit-code.md | 68 +++++++++++++++++++++++++++++ teps/README.md | 1 + 2 files changed, 69 insertions(+) create mode 100644 teps/0040-capture-step-exit-code.md diff --git a/teps/0040-capture-step-exit-code.md b/teps/0040-capture-step-exit-code.md new file mode 100644 index 000000000..8314ab5cf --- /dev/null +++ b/teps/0040-capture-step-exit-code.md @@ -0,0 +1,68 @@ +--- +status: proposed +title: 'Capture Step Exit Code' +creation-date: '2021-01-06' +last-updated: '2021-01-06' +authors: +- '@pritidesai' +- '@afrittoli' +--- + +# TEP-0040: Capture Step Exit Code + + +- [Summary](#summary) +- [Motivation](#motivation) + - [Goals](#goals) + - [Non-Goals](#non-goals) + - [Use Cases](#use-cases) +- [References](#references) + + +## Summary + +Tekton tasks are defined as a collection of steps in which each step can specify a container image to run. +Steps are executed in order in which they are specified. One single step failure results in a task failure +in turn results in a pipeline failure. Once a step results in failure, rest of the steps are not executed. + +Many common pipelines have requirement where a step failure must not halt the entire execution. In order to +continue executing a task even if a step fail, pipeline authors have flexibility of wrapping an image and +exiting that task with success. This changes the failing task into success and does not block further +execution. This is a workaround and only works with images which can be wrapped. This workaround does not apply +to off-the-shelf container images. + +As a pipeline execution engine, we want to support off-the-shelf container image as a step and provide +an option to capture non-zero exit code. The pipeline author can choose to continue execution after capturing +the non-zero exit code and make it available to access it after the execution. + +Issue: [tektoncd/pipeline#2800](https://github.com/tektoncd/pipeline/issues/2800) + + +## Motivation + +It should be possible to easily use off-the-shelves (OTS) images as steps in Tekton tasks. A task author has no +control on the image but may desire to capture an error and continue executing the pipeline. + +### Goals + +Design a step failure strategy so that the task author can control the behaviour of the image and decide to +continue execution or not. + +Store the container termination state or error state and make it accessible after the pipeline finishes execution. + +This proposal must be applicable to any container image including custom images and off-the-shelf images. + +### Non-Goals + +This design is limited to a step within a task and does not apply to pipeline tasks. + +### Use Cases + +As a pipeline author, I would like to design a task with multiple steps. One of the steps is running an +enterprise image to run unit tests, and the next step needs to report test results even after a previous +step results in failure due to tests failure. + + +## References + +* https://github.com/tektoncd/pipeline/issues/2800 \ No newline at end of file diff --git a/teps/README.md b/teps/README.md index 1027750c4..c75ce6c8a 100644 --- a/teps/README.md +++ b/teps/README.md @@ -147,3 +147,4 @@ This is the complete list of Tekton teps: |[TEP-0032](0032-tekton-notifications.md) | Tekton Notifications | proposed | 2020-11-18 | |[TEP-0035](0035-document-tekton-position-around-policy-authentication-authorization.md) | document-tekton-position-around-policy-authentication-authorization | implementable | 2020-12-09 | |[TEP-0036](0036-start-measuring-tekton-pipelines-performance.md) | Start Measuring Tekton Pipelines Performance | proposed | 2020-11-20 | +|[TEP-0040](0040-capture-step-exit-code.md) | Capture Step Exit Code | proposed | 2021-01-06 |