1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

libcontainerd: mark container exited after failed restart

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2016-08-03 15:28:52 -07:00
parent 495448b290
commit 9be0fb45c2
2 changed files with 10 additions and 5 deletions

View file

@ -190,6 +190,11 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
ctr.client.lock(ctr.containerID) ctr.client.lock(ctr.containerID)
defer ctr.client.unlock(ctr.containerID) defer ctr.client.unlock(ctr.containerID)
ctr.restarting = false ctr.restarting = false
if err == nil {
if err = ctr.start(); err != nil {
logrus.Errorf("libcontainerd: error restarting %v", err)
}
}
if err != nil { if err != nil {
st.State = StateExit st.State = StateExit
ctr.clean() ctr.clean()
@ -201,8 +206,6 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
if err != restartmanager.ErrRestartCanceled { if err != restartmanager.ErrRestartCanceled {
logrus.Errorf("libcontainerd: %v", err) logrus.Errorf("libcontainerd: %v", err)
} }
} else {
ctr.start()
} }
}() }()
} }

View file

@ -260,14 +260,16 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
err := <-waitRestart err := <-waitRestart
ctr.restarting = false ctr.restarting = false
ctr.client.deleteContainer(ctr.friendlyName) ctr.client.deleteContainer(ctr.friendlyName)
if err == nil {
if err = ctr.client.Create(ctr.containerID, ctr.ociSpec, ctr.options...); err != nil {
logrus.Errorf("libcontainerd: error restarting %v", err)
}
}
if err != nil { if err != nil {
si.State = StateExit si.State = StateExit
if err := ctr.client.backend.StateChanged(ctr.containerID, si); err != nil { if err := ctr.client.backend.StateChanged(ctr.containerID, si); err != nil {
logrus.Error(err) logrus.Error(err)
} }
logrus.Error(err)
} else {
ctr.client.Create(ctr.containerID, ctr.ociSpec, ctr.options...)
} }
}() }()
} }