From 4a00ea557c6e60cdd131b2a9866aa3b0bcb9cb2c Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Thu, 4 Oct 2018 11:00:40 -0700 Subject: Capture boot panics in debug log. Docker and Containerd both eat the boot processes stderr, making it difficult to track down panics (which are always written to stderr). This CL makes the boot process dup its debug log FD to stderr, so that panics will be captured in the debug log, which is better than nothing. This is the 3rd try at this CL. Previous attempts were foiled because Docker expects the 'create' command to pass its stdio directly to the container, so duping stderr in 'create' caused the applications stderr to go to the log file, which breaks many applications (including our mysql test). I added a new image_test that makes sure stdout and stderr are handled correctly. PiperOrigin-RevId: 215767328 Change-Id: Icebac5a5dcf39b623b79d7a0e2f968e059130059 --- runsc/test/image/image_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'runsc/test') diff --git a/runsc/test/image/image_test.go b/runsc/test/image/image_test.go index 341bdc1d5..428f05c04 100644 --- a/runsc/test/image/image_test.go +++ b/runsc/test/image/image_test.go @@ -303,6 +303,27 @@ func TestRuby(t *testing.T) { } } +func TestStdio(t *testing.T) { + if err := testutil.Pull("alpine"); err != nil { + t.Fatalf("docker pull failed: %v", err) + } + d := testutil.MakeDocker("stdio-test") + + wantStdout := "hello stdout" + wantStderr := "bonjour stderr" + cmd := fmt.Sprintf("echo %q; echo %q 1>&2;", wantStdout, wantStderr) + if err := d.Run("alpine", "/bin/sh", "-c", cmd); err != nil { + t.Fatalf("docker run failed: %v", err) + } + defer d.CleanUp() + + for _, want := range []string{wantStdout, wantStderr} { + if _, err := d.WaitForOutput(want, 5*time.Second); err != nil { + t.Fatalf("docker didn't get output %q : %v", want, err) + } + } +} + func TestMain(m *testing.M) { testutil.EnsureSupportedDockerVersion() os.Exit(m.Run()) -- cgit v1.2.3