Skip to content

Commit 9be0fb4

Browse files
committed
libcontainerd: mark container exited after failed restart
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 495448b commit 9be0fb4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

libcontainerd/container_linux.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
190190
ctr.client.lock(ctr.containerID)
191191
defer ctr.client.unlock(ctr.containerID)
192192
ctr.restarting = false
193+
if err == nil {
194+
if err = ctr.start(); err != nil {
195+
logrus.Errorf("libcontainerd: error restarting %v", err)
196+
}
197+
}
193198
if err != nil {
194199
st.State = StateExit
195200
ctr.clean()
@@ -201,8 +206,6 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
201206
if err != restartmanager.ErrRestartCanceled {
202207
logrus.Errorf("libcontainerd: %v", err)
203208
}
204-
} else {
205-
ctr.start()
206209
}
207210
}()
208211
}

libcontainerd/container_windows.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,16 @@ func (ctr *container) waitExit(process *process, isFirstProcessToStart bool) err
260260
err := <-waitRestart
261261
ctr.restarting = false
262262
ctr.client.deleteContainer(ctr.friendlyName)
263+
if err == nil {
264+
if err = ctr.client.Create(ctr.containerID, ctr.ociSpec, ctr.options...); err != nil {
265+
logrus.Errorf("libcontainerd: error restarting %v", err)
266+
}
267+
}
263268
if err != nil {
264269
si.State = StateExit
265270
if err := ctr.client.backend.StateChanged(ctr.containerID, si); err != nil {
266271
logrus.Error(err)
267272
}
268-
logrus.Error(err)
269-
} else {
270-
ctr.client.Create(ctr.containerID, ctr.ociSpec, ctr.options...)
271273
}
272274
}()
273275
}

0 commit comments

Comments
 (0)