Skip to content

Commit

Permalink
libcontainerd: mark container exited after failed restart
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Aug 4, 2016
1 parent 495448b commit 9be0fb4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions libcontainerd/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
ctr.client.lock(ctr.containerID)
defer ctr.client.unlock(ctr.containerID)
ctr.restarting = false
if err == nil {
if err = ctr.start(); err != nil {
logrus.Errorf("libcontainerd: error restarting %v", err)
}
}
if err != nil {
st.State = StateExit
ctr.clean()
Expand All @@ -201,8 +206,6 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
if err != restartmanager.ErrRestartCanceled {
logrus.Errorf("libcontainerd: %v", err)
}
} else {
ctr.start()
}
}()
}
Expand Down
8 changes: 5 additions & 3 deletions libcontainerd/container_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,16 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
err := <-waitRestart
ctr.restarting = false
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 {
si.State = StateExit
if err := ctr.client.backend.StateChanged(ctr.containerID, si); err != nil {
logrus.Error(err)
}
logrus.Error(err)
} else {
ctr.client.Create(ctr.containerID, ctr.ociSpec, ctr.options...)
}
}()
}
Expand Down

0 comments on commit 9be0fb4

Please sign in to comment.