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

Change "fail" to "stopAndFail" 🧐 #4151

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
timeout = flag.Duration("timeout", time.Duration(0), "If specified, sets timeout for step")
breakpointOnFailure = flag.Bool("breakpoint_on_failure", false, "If specified, expect steps to not skip on failure")
onError = flag.String("on_error", "", "Set to \"continue\" to ignore an error and continue when a container terminates with a non-zero exit code."+
" Set to \"fail\" to declare a failure with a step error and stop executing the rest of the steps.")
" Set to \"stopAndFail\" to declare a failure with a step error and stop executing the rest of the steps.")
stepMetadataDir = flag.String("step_metadata_dir", "", "If specified, create directory to store the step metadata e.g. /tekton/steps/<step-name>/")
stepMetadataDirLink = flag.String("step_metadata_dir_link", "", "creates a symbolic link to the specified step_metadata_dir e.g. /tekton/steps/<step-index>/")
)
Expand Down
2 changes: 1 addition & 1 deletion docs/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ When a `step` in a `task` results in a failure, the rest of the steps in the `ta
declared a failure. If you would like to ignore such step errors and continue executing the rest of the steps in
the task, you can specify `onError` for such a `step`.

`onError` can be set to either `continue` or `fail` as part of the step definition. If `onError` is
`onError` can be set to either `continue` or `stopAndFail` as part of the step definition. If `onError` is
set to `continue`, the entrypoint sets the original failed exit code of the [script](#running-scripts-within-steps)
in the container terminated state. A `step` with `onError` set to `continue` does not fail the `taskRun` and continues
executing the rest of the steps in a task.
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@
"default": ""
},
"onError": {
"description": "OnError defines the exiting behavior of a container on error can be set to [ continue | fail ] fail indicates exit the taskRun if the container exits with non-zero exit code continue indicates continue executing the rest of the steps irrespective of the container exit code",
"description": "OnError defines the exiting behavior of a container on error can be set to [ continue | stopAndFail ] stopAndFail indicates exit the taskRun if the container exits with non-zero exit code continue indicates continue executing the rest of the steps irrespective of the container exit code",
"type": "string"
},
"ports": {
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1beta1/task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ type Step struct {
Workspaces []WorkspaceUsage `json:"workspaces,omitempty"`

// OnError defines the exiting behavior of a container on error
// can be set to [ continue | fail ]
// fail indicates exit the taskRun if the container exits with non-zero exit code
// can be set to [ continue | stopAndFail ]
// stopAndFail indicates exit the taskRun if the container exits with non-zero exit code
// continue indicates continue executing the rest of the steps irrespective of the container exit code
OnError string `json:"onError,omitempty"`
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1beta1/task_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ func validateStep(ctx context.Context, s Step, names sets.String) (errs *apis.Fi

if s.OnError != "" {
errs = errs.Also(ValidateEnabledAPIFields(ctx, "step onError", config.AlphaAPIFields).ViaField("steps"))
if s.OnError != "continue" && s.OnError != "fail" {
if s.OnError != "continue" && s.OnError != "stopAndFail" {
errs = errs.Also(&apis.FieldError{
Message: fmt.Sprintf("invalid value: %v", s.OnError),
Paths: []string{"onError"},
Details: "Task step onError must be either continue or fail",
Details: "Task step onError must be either continue or stopAndFail",
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/pipeline/v1beta1/task_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1150,9 +1150,9 @@ func TestStepOnError(t *testing.T) {
},
}},
}, {
name: "valid step - valid onError usage - set to fail - alpha API",
name: "valid step - valid onError usage - set to stopAndFail - alpha API",
steps: []v1beta1.Step{{
OnError: "fail",
OnError: "stopAndFail",
Container: corev1.Container{
Image: "image",
Args: []string{"arg"},
Expand All @@ -1170,7 +1170,7 @@ func TestStepOnError(t *testing.T) {
expectedError: &apis.FieldError{
Message: fmt.Sprintf("invalid value: onError"),
Paths: []string{"onError"},
Details: "Task step onError must be either continue or fail",
Details: "Task step onError must be either continue or stopAndFail",
},
}}
for _, tt := range tests {
Expand Down
4 changes: 2 additions & 2 deletions pkg/entrypoint/entrypointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
const (
timeFormat = "2006-01-02T15:04:05.000Z07:00"
ContinueOnError = "continue"
FailOnError = "fail"
FailOnError = "stopAndFail"
)

// Entrypointer holds fields for running commands with redirected
Expand Down Expand Up @@ -76,7 +76,7 @@ type Entrypointer struct {
// BreakpointOnFailure helps determine if entrypoint execution needs to adapt debugging requirements
BreakpointOnFailure bool
// OnError defines exiting behavior of the entrypoint
// set it to "fail" to indicate the entrypoint to exit the taskRun if the container exits with non zero exit code
// set it to "stopAndFail" to indicate the entrypoint to exit the taskRun if the container exits with non zero exit code
// set it to "continue" to indicate the entrypoint to continue executing the rest of the steps irrespective of the container exit code
OnError string
// StepMetadataDir is the directory for a step where the step related metadata can be stored
Expand Down
4 changes: 2 additions & 2 deletions pkg/entrypoint/entrypointer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ func TestEntrypointer_OnError(t *testing.T) {
onError: ContinueOnError,
expectedError: false,
}, {
desc: "the step is exiting with 1, treat the step error as failure with onError set to fail",
desc: "the step is exiting with 1, treat the step error as failure with onError set to stopAndFail",
runner: &fakeExitErrorRunner{},
expectedError: true,
postFile: "step-one",
onError: FailOnError,
}, {
desc: "the step is exiting with 0, treat the step error (but there is none) as failure with onError set to fail",
desc: "the step is exiting with 0, treat the step error (but there is none) as failure with onError set to stopAndFail",
runner: &fakeRunner{},
postFile: "step-one",
onError: FailOnError,
Expand Down
2 changes: 1 addition & 1 deletion pkg/pod/entrypoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func TestEntryPointOnError(t *testing.T) {
"-termination_path", "/tekton/termination",
"-step_metadata_dir", "/tekton/steps/step-passing-step",
"-step_metadata_dir_link", "/tekton/steps/1",
"-on_error", "fail",
"-on_error", "stopAndFail",
"-entrypoint", "cmd", "--",
},
VolumeMounts: []corev1.VolumeMount{toolsMount},
Expand Down