mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Honor the restarting state in Stop
Signed-off-by: Michael Crosby <michael@docker.com>
This commit is contained in:
parent
a2afb2b1e3
commit
c4a00d549d
3 changed files with 18 additions and 10 deletions
|
@ -530,6 +530,13 @@ func (container *Container) KillSig(sig int) error {
|
|||
// after we send the kill signal
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -116,16 +116,15 @@ func (m *containerMonitor) Start() error {
|
|||
time.Sleep(time.Duration(m.timeIncrement) * time.Millisecond)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
m.container.State.SetStopped(exitStatus)
|
||||
|
||||
m.resetContainer()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -31,14 +31,13 @@ func (s *State) String() string {
|
|||
s.RLock()
|
||||
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.Paused {
|
||||
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)))
|
||||
}
|
||||
|
@ -148,7 +147,10 @@ func (s *State) SetStopped(exitCode int) {
|
|||
func (s *State) SetRestarting(exitCode int) {
|
||||
s.Lock()
|
||||
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.FinishedAt = time.Now().UTC()
|
||||
s.ExitCode = exitCode
|
||||
|
|
Loading…
Add table
Reference in a new issue