Skip to content

Commit

Permalink
Exit with a non-zero exit code when we skip a command in the entrypoi…
Browse files Browse the repository at this point in the history
…nter.

When an early step fails, our entrypointer correctly skips all subsequent steps.
Unfortunately, the containers currently exit with 0 which may be interpreted as
these steps having successfully completed.

Fixes #1439
  • Loading branch information
dlorenc committed Oct 30, 2019
1 parent fe47335 commit 4da8725
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func main() {
if err := e.Go(); err != nil {
switch t := err.(type) {
case skipError:
os.Exit(0)
log.Print("Skipping step because a previous step failed")
os.Exit(1)
case *exec.ExitError:
// Copied from https://stackoverflow.com/questions/10385551/get-exit-code-go
// This works on both Unix and Windows. Although
Expand Down
4 changes: 2 additions & 2 deletions test/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func TestTaskRunFailure(t *testing.T) {
}, {
ContainerState: corev1.ContainerState{
Terminated: &corev1.ContainerStateTerminated{
ExitCode: 0,
Reason: "Completed",
ExitCode: 1,
Reason: "Error",
},
},
Name: "world",
Expand Down

0 comments on commit 4da8725

Please sign in to comment.