From e7df1fbc8be086a0b9cb091ac4c27de5736d13e5 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 3 Sep 2019 09:53:06 -0400 Subject: [PATCH] Accept any sidecar termination Reason as success Fixes #1253 When a sidecar is forcefully exited by the taskrun controller it may error out. This happens because the sidecar is terminated by having its image field rewritten to be tekton's nop container. The nop container is bare bones and probably doesnt contain the entrypoint command configured for the sidecar. When this occurs the container will exit with an error of some kind. On GKE this error's Reason is "ContainerCannotRun" but on MiniShift/OpenShift the error Reason is "Error". The sidecar e2e test previously required a termination Reason of "ContainerCannotRun" or "Completed" but this appears to be too rigid. Instead the test now considers a sidecar that has been terminated for any reason to be a success. --- test/sidecar_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sidecar_test.go b/test/sidecar_test.go index 0a64aa35e15..1d63a68ab47 100644 --- a/test/sidecar_test.go +++ b/test/sidecar_test.go @@ -122,14 +122,14 @@ func TestSidecarTaskSupport(t *testing.T) { for _, c := range pod.Status.ContainerStatuses { if c.Name == fmt.Sprintf("step-%s", primaryContainerName) { if c.State.Terminated == nil || c.State.Terminated.Reason != "Completed" { - t.Errorf("Primary container did not terminate as expected, Terminated state: %v", c.State.Terminated) + t.Errorf("Primary container has nil Terminated state or did not complete successfully. Actual Terminated state: %v", c.State.Terminated) } else { primaryTerminated = true } } if c.Name == sidecarContainerName { - if c.State.Terminated == nil || (c.State.Terminated.Reason != "Completed" && c.State.Terminated.Reason != "ContainerCannotRun") { - t.Errorf("Sidecar container did not terminate as expected, Terminated state: %v", c.State.Terminated) + if c.State.Terminated == nil { + t.Errorf("Sidecar container has a nil Terminated status but non-nil is expected.") } else { sidecarTerminated = true }