summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Crosby <crosbymichael@gmail.com>2016-07-27 09:21:13 -0700
committerMichael Crosby <crosbymichael@gmail.com>2016-07-28 09:22:51 -0700
commiteddee8e9328dd8decff4f492045798a7d0867fde (patch)
tree36ba61e3d794075b8e77e54bfd4a158d111fbd05
parent664fcd9f287c295a603cc7f230b9b4843e65eab6 (diff)
downloaddocker-eddee8e9328dd8decff4f492045798a7d0867fde.tar.gz
Check if the container is running if no event
When there is no event for the container it can happen because of a crash and the container state on the persistent disk will have a mismatch between what was in `/run` ( machine crash ). This situation will create an unkillable container in docker because containerd does not see it and it is not running but docker thinks it is and you cannot tell it anything different. This fixes the issue by checking if containerd has the container running if we do not have an event instead of just returning. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
-rw-r--r--libcontainerd/client_linux.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/libcontainerd/client_linux.go b/libcontainerd/client_linux.go
index afb68b4a45..99d299f555 100644
--- a/libcontainerd/client_linux.go
+++ b/libcontainerd/client_linux.go
@@ -505,12 +505,20 @@ func (clnt *client) Restore(containerID string, options ...CreateOption) error {
return err
}
- // If ev is nil, then we already consumed all the event of the
- // container, included the "exit" one.
- // Thus we return to avoid overriding the Exit Code.
if ev == nil {
- logrus.Warnf("libcontainerd: restore was called on a fully synced container (%s)", containerID)
- return nil
+ if _, err := clnt.getContainer(containerID); err == nil {
+ // If ev is nil and the container is running in containerd,
+ // we already consumed all the event of the
+ // container, included the "exit" one.
+ // Thus we return to avoid overriding the Exit Code.
+ logrus.Warnf("libcontainerd: restore was called on a fully synced container (%s)", containerID)
+ return nil
+ }
+ // the container is not running so we need to fix the state within docker
+ ev = &containerd.Event{
+ Type: StateExit,
+ Status: 1,
+ }
}
// get the exit status for this container