Signed-off-by: Michael Crosby <michael@docker.com>
| ... | ... |
@@ -530,6 +530,13 @@ func (container *Container) KillSig(sig int) error {
|
| 530 | 530 |
// after we send the kill signal |
| 531 | 531 |
container.monitor.ExitOnNext() |
| 532 | 532 |
|
| 533 |
+ // if the container is currently restarting we do not need to send the signal |
|
| 534 |
+ // to the process. Telling the monitor that it should exit on it's next event |
|
| 535 |
+ // loop is enough |
|
| 536 |
+ if container.State.IsRestarting() {
|
|
| 537 |
+ return nil |
|
| 538 |
+ } |
|
| 539 |
+ |
|
| 533 | 540 |
return container.daemon.Kill(container, sig) |
| 534 | 541 |
} |
| 535 | 542 |
|
| ... | ... |
@@ -116,16 +116,15 @@ func (m *containerMonitor) Start() error {
|
| 116 | 116 |
time.Sleep(time.Duration(m.timeIncrement) * time.Millisecond) |
| 117 | 117 |
|
| 118 | 118 |
continue |
| 119 |
- } else {
|
|
| 120 |
- // we still wait to set the state as stopped and ensure that the locks were released |
|
| 121 |
- m.container.State.SetStopped(exitStatus) |
|
| 122 |
- |
|
| 123 |
- m.resetContainer() |
|
| 124 | 119 |
} |
| 125 | 120 |
|
| 126 | 121 |
break |
| 127 | 122 |
} |
| 128 | 123 |
|
| 124 |
+ m.container.State.SetStopped(exitStatus) |
|
| 125 |
+ |
|
| 126 |
+ m.resetContainer() |
|
| 127 |
+ |
|
| 129 | 128 |
return err |
| 130 | 129 |
} |
| 131 | 130 |
|
| ... | ... |
@@ -31,14 +31,13 @@ func (s *State) String() string {
|
| 31 | 31 |
s.RLock() |
| 32 | 32 |
defer s.RUnlock() |
| 33 | 33 |
|
| 34 |
- if s.Restarting {
|
|
| 35 |
- return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
|
|
| 36 |
- } |
|
| 37 |
- |
|
| 38 | 34 |
if s.Running {
|
| 39 | 35 |
if s.Paused {
|
| 40 | 36 |
return fmt.Sprintf("Up %s (Paused)", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
|
| 41 | 37 |
} |
| 38 |
+ if s.Restarting {
|
|
| 39 |
+ return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
|
|
| 40 |
+ } |
|
| 42 | 41 |
|
| 43 | 42 |
return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
|
| 44 | 43 |
} |
| ... | ... |
@@ -148,7 +147,10 @@ func (s *State) SetStopped(exitCode int) {
|
| 148 | 148 |
func (s *State) SetRestarting(exitCode int) {
|
| 149 | 149 |
s.Lock() |
| 150 | 150 |
if s.Running {
|
| 151 |
- s.Running = false |
|
| 151 |
+ // we should consider the container running when it is restarting because of |
|
| 152 |
+ // all the checks in docker around rm/stop/etc |
|
| 153 |
+ s.Running = true |
|
| 154 |
+ s.Restarting = true |
|
| 152 | 155 |
s.Pid = 0 |
| 153 | 156 |
s.FinishedAt = time.Now().UTC() |
| 154 | 157 |
s.ExitCode = exitCode |