-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
entrypoint: in case of step command failure, write postfile
The entrypoint package wraps the step commands and execute them. This allows use to use pods containers with some order. In a step, the entrypoint binary will wait for the file of the previous step to be present to execute the actual command. Before this change, if a command failed (`exit 1` or something), entrypoint would not write a file, and thus the whole pod would be stuck running (all the next step would wait forever). This fixes that by always writing the post-file — and making the *waiter* a bit smarter : - it will now look for a `{postfile}.err` to detect if the previous step failed or not. - if the previous steps failed, it will fail too without executing the step commands. Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
- Loading branch information
1 parent
2f7dbd9
commit d86f71b
Showing
4 changed files
with
127 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// +build e2e | ||
|
||
/* | ||
Copyright 2018 The Knative Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
knativetest "github.com/knative/pkg/test" | ||
tb "github.com/tektoncd/pipeline/test/builder" | ||
) | ||
|
||
func TestTaskRunFailure(t *testing.T) { | ||
c, namespace := setup(t) | ||
t.Parallel() | ||
|
||
knativetest.CleanupOnInterrupt(func() { tearDown(t, c, namespace) }, t.Logf) | ||
defer tearDown(t, c, namespace) | ||
|
||
t.Logf("Creating Task and TaskRun in namespace %s", namespace) | ||
task := tb.Task("failing-task", namespace, tb.TaskSpec( | ||
tb.Step("hello", "busybox", | ||
tb.Command("/bin/sh"), tb.Args("-c", "echo hello"), | ||
), | ||
tb.Step("exit", "busybox", | ||
tb.Command("/bin/sh"), tb.Args("-c", "exit 1"), | ||
), | ||
tb.Step("world", "busybox", | ||
tb.Command("/bin/sh"), tb.Args("-c", "sleep 20s"), | ||
), | ||
)) | ||
if _, err := c.TaskClient.Create(task); err != nil { | ||
t.Fatalf("Failed to create Task: %s", err) | ||
} | ||
taskRun := tb.TaskRun("failing-taskrun", namespace, tb.TaskRunSpec( | ||
tb.TaskRunTaskRef("failing-task"), | ||
)) | ||
if _, err := c.TaskRunClient.Create(taskRun); err != nil { | ||
t.Fatalf("Failed to create TaskRun: %s", err) | ||
} | ||
|
||
t.Logf("Waiting for TaskRun in namespace %s to fail", namespace) | ||
if err := WaitForTaskRunState(c, "failing-taskrun", TaskRunFailed("failing-taskrun"), "TaskRunFailed"); err != nil { | ||
t.Errorf("Error waiting for TaskRun to finish: %s", err) | ||
} | ||
} |