mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Fix restart monitor stopping on manual restart
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
		
							parent
							
								
									14015eedb1
								
							
						
					
					
						commit
						20390f65c4
					
				
					 2 changed files with 31 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -909,6 +909,7 @@ func (container *Container) FullHostname() string {
 | 
			
		|||
func (container *Container) RestartManager(reset bool) restartmanager.RestartManager {
 | 
			
		||||
	if reset {
 | 
			
		||||
		container.RestartCount = 0
 | 
			
		||||
		container.restartManager = nil
 | 
			
		||||
	}
 | 
			
		||||
	if container.restartManager == nil {
 | 
			
		||||
		container.restartManager = restartmanager.New(container.HostConfig.RestartPolicy)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -188,3 +188,33 @@ func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *check.C) {
 | 
			
		|||
	_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "foo")
 | 
			
		||||
	c.Assert(err, check.IsNil)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *DockerSuite) TestRestartPolicyAfterRestart(c *check.C) {
 | 
			
		||||
	testRequires(c, SameHostDaemon)
 | 
			
		||||
 | 
			
		||||
	out, _ := runSleepingContainer(c, "-d", "--restart=always")
 | 
			
		||||
	id := strings.TrimSpace(out)
 | 
			
		||||
	c.Assert(waitRun(id), check.IsNil)
 | 
			
		||||
 | 
			
		||||
	dockerCmd(c, "restart", id)
 | 
			
		||||
 | 
			
		||||
	c.Assert(waitRun(id), check.IsNil)
 | 
			
		||||
 | 
			
		||||
	pidStr := inspectField(c, id, "State.Pid")
 | 
			
		||||
 | 
			
		||||
	pid, err := strconv.Atoi(pidStr)
 | 
			
		||||
	c.Assert(err, check.IsNil)
 | 
			
		||||
 | 
			
		||||
	p, err := os.FindProcess(pid)
 | 
			
		||||
	c.Assert(err, check.IsNil)
 | 
			
		||||
	c.Assert(p, check.NotNil)
 | 
			
		||||
 | 
			
		||||
	err = p.Kill()
 | 
			
		||||
	c.Assert(err, check.IsNil)
 | 
			
		||||
 | 
			
		||||
	err = waitInspect(id, "{{.RestartCount}}", "1", 30*time.Second)
 | 
			
		||||
	c.Assert(err, check.IsNil)
 | 
			
		||||
 | 
			
		||||
	err = waitInspect(id, "{{.State.Status}}", "running", 30*time.Second)
 | 
			
		||||
	c.Assert(err, check.IsNil)
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue