Honor the restarting state in Stop
Signed-off-by: Michael Crosby <michael@docker.com>
This commit is contained in:
parent
a2afb2b1e3
commit
c4a00d549d
|
|
@ -530,6 +530,13 @@ func (container *Container) KillSig(sig int) error {
|
||||||
// after we send the kill signal
|
// after we send the kill signal
|
||||||
container.monitor.ExitOnNext()
|
container.monitor.ExitOnNext()
|
||||||
|
|
||||||
|
// if the container is currently restarting we do not need to send the signal
|
||||||
|
// to the process. Telling the monitor that it should exit on it's next event
|
||||||
|
// loop is enough
|
||||||
|
if container.State.IsRestarting() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return container.daemon.Kill(container, sig)
|
return container.daemon.Kill(container, sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,16 +116,15 @@ func (m *containerMonitor) Start() error {
|
||||||
time.Sleep(time.Duration(m.timeIncrement) * time.Millisecond)
|
time.Sleep(time.Duration(m.timeIncrement) * time.Millisecond)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
} else {
|
|
||||||
// we still wait to set the state as stopped and ensure that the locks were released
|
|
||||||
m.container.State.SetStopped(exitStatus)
|
|
||||||
|
|
||||||
m.resetContainer()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.container.State.SetStopped(exitStatus)
|
||||||
|
|
||||||
|
m.resetContainer()
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,13 @@ func (s *State) String() string {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
|
|
||||||
if s.Restarting {
|
|
||||||
return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.Running {
|
if s.Running {
|
||||||
if s.Paused {
|
if s.Paused {
|
||||||
return fmt.Sprintf("Up %s (Paused)", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
|
return fmt.Sprintf("Up %s (Paused)", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
|
||||||
}
|
}
|
||||||
|
if s.Restarting {
|
||||||
|
return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
|
||||||
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
|
return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +147,10 @@ func (s *State) SetStopped(exitCode int) {
|
||||||
func (s *State) SetRestarting(exitCode int) {
|
func (s *State) SetRestarting(exitCode int) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
if s.Running {
|
if s.Running {
|
||||||
s.Running = false
|
// we should consider the container running when it is restarting because of
|
||||||
|
// all the checks in docker around rm/stop/etc
|
||||||
|
s.Running = true
|
||||||
|
s.Restarting = true
|
||||||
s.Pid = 0
|
s.Pid = 0
|
||||||
s.FinishedAt = time.Now().UTC()
|
s.FinishedAt = time.Now().UTC()
|
||||||
s.ExitCode = exitCode
|
s.ExitCode = exitCode
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue