Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -909,6 +909,7 @@ func (container *Container) FullHostname() string {
|
| 909 | 909 |
func (container *Container) RestartManager(reset bool) restartmanager.RestartManager {
|
| 910 | 910 |
if reset {
|
| 911 | 911 |
container.RestartCount = 0 |
| 912 |
+ container.restartManager = nil |
|
| 912 | 913 |
} |
| 913 | 914 |
if container.restartManager == nil {
|
| 914 | 915 |
container.restartManager = restartmanager.New(container.HostConfig.RestartPolicy) |
| ... | ... |
@@ -188,3 +188,33 @@ func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *check.C) {
|
| 188 | 188 |
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "foo")
|
| 189 | 189 |
c.Assert(err, check.IsNil) |
| 190 | 190 |
} |
| 191 |
+ |
|
| 192 |
+func (s *DockerSuite) TestRestartPolicyAfterRestart(c *check.C) {
|
|
| 193 |
+ testRequires(c, SameHostDaemon) |
|
| 194 |
+ |
|
| 195 |
+ out, _ := runSleepingContainer(c, "-d", "--restart=always") |
|
| 196 |
+ id := strings.TrimSpace(out) |
|
| 197 |
+ c.Assert(waitRun(id), check.IsNil) |
|
| 198 |
+ |
|
| 199 |
+ dockerCmd(c, "restart", id) |
|
| 200 |
+ |
|
| 201 |
+ c.Assert(waitRun(id), check.IsNil) |
|
| 202 |
+ |
|
| 203 |
+ pidStr := inspectField(c, id, "State.Pid") |
|
| 204 |
+ |
|
| 205 |
+ pid, err := strconv.Atoi(pidStr) |
|
| 206 |
+ c.Assert(err, check.IsNil) |
|
| 207 |
+ |
|
| 208 |
+ p, err := os.FindProcess(pid) |
|
| 209 |
+ c.Assert(err, check.IsNil) |
|
| 210 |
+ c.Assert(p, check.NotNil) |
|
| 211 |
+ |
|
| 212 |
+ err = p.Kill() |
|
| 213 |
+ c.Assert(err, check.IsNil) |
|
| 214 |
+ |
|
| 215 |
+ err = waitInspect(id, "{{.RestartCount}}", "1", 30*time.Second)
|
|
| 216 |
+ c.Assert(err, check.IsNil) |
|
| 217 |
+ |
|
| 218 |
+ err = waitInspect(id, "{{.State.Status}}", "running", 30*time.Second)
|
|
| 219 |
+ c.Assert(err, check.IsNil) |
|
| 220 |
+} |