Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
| ... | ... |
@@ -2764,3 +2764,41 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *check.C) |
| 2764 | 2764 |
c.Assert(out, checker.Contains, "top1", check.Commentf("top1 should exist after daemon restarts"))
|
| 2765 | 2765 |
c.Assert(out, checker.Not(checker.Contains), "top2", check.Commentf("top2 should be removed after daemon restarts"))
|
| 2766 | 2766 |
} |
| 2767 |
+ |
|
| 2768 |
+func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *check.C) {
|
|
| 2769 |
+ err := s.d.StartWithBusybox() |
|
| 2770 |
+ c.Assert(err, checker.IsNil) |
|
| 2771 |
+ |
|
| 2772 |
+ containerName := "error-values" |
|
| 2773 |
+ runError := "oci runtime error: exec: \"toto\": executable file not found in $PATH" |
|
| 2774 |
+ // Make a container with both a non 0 exit code and an error message |
|
| 2775 |
+ out, err := s.d.Cmd("run", "--name", containerName, "busybox", "toto")
|
|
| 2776 |
+ c.Assert(err, checker.NotNil) |
|
| 2777 |
+ c.Assert(out, checker.Contains, runError) |
|
| 2778 |
+ |
|
| 2779 |
+ // Check that those values were saved on disk |
|
| 2780 |
+ out, err = s.d.Cmd("inspect", "-f", "{{.State.ExitCode}}", containerName)
|
|
| 2781 |
+ out = strings.TrimSpace(out) |
|
| 2782 |
+ c.Assert(err, checker.IsNil) |
|
| 2783 |
+ c.Assert(out, checker.Equals, "127") |
|
| 2784 |
+ |
|
| 2785 |
+ out, err = s.d.Cmd("inspect", "-f", "{{.State.Error}}", containerName)
|
|
| 2786 |
+ out = strings.TrimSpace(out) |
|
| 2787 |
+ c.Assert(err, checker.IsNil) |
|
| 2788 |
+ c.Assert(out, checker.Equals, runError) |
|
| 2789 |
+ |
|
| 2790 |
+ // now restart daemon |
|
| 2791 |
+ err = s.d.Restart() |
|
| 2792 |
+ c.Assert(err, checker.IsNil) |
|
| 2793 |
+ |
|
| 2794 |
+ // Check that those values are still around |
|
| 2795 |
+ out, err = s.d.Cmd("inspect", "-f", "{{.State.ExitCode}}", containerName)
|
|
| 2796 |
+ out = strings.TrimSpace(out) |
|
| 2797 |
+ c.Assert(err, checker.IsNil) |
|
| 2798 |
+ c.Assert(out, checker.Equals, "127") |
|
| 2799 |
+ |
|
| 2800 |
+ out, err = s.d.Cmd("inspect", "-f", "{{.State.Error}}", containerName)
|
|
| 2801 |
+ out = strings.TrimSpace(out) |
|
| 2802 |
+ c.Assert(err, checker.IsNil) |
|
| 2803 |
+ c.Assert(out, checker.Equals, runError) |
|
| 2804 |
+} |