From c2a3ad69bb340f15e075b5156ea5a55fb6bf7bad Mon Sep 17 00:00:00 2001 From: Ace-Tang Date: Fri, 1 Nov 2019 12:10:10 +0800 Subject: [PATCH] ctrd: fix task unexpected exit time="2019-11-01T09:54:30.981479019+08:00" level=info msg="the task has quit, id: e3954a23946f1415f3ed2f0010024536a119a3645bf4cdc884c04e33b725ae1e, err: rpc error: code = Canceled desc = context canceled, exitcode: 255, time: 0001-01-01 00:00:00 +0000 UTC" ContainerID=e3954a23946f1415f3ed2f0010024536a119a3645bf4cdc884c04e33b725ae1e get task exit message, this caused by grpc server stop first, but pouch still running, task will got this message Signed-off-by: Ace-Tang --- ctrd/watch.go | 9 ++++++++- daemon/daemon.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ctrd/watch.go b/ctrd/watch.go index 319490a4c..06b6645f8 100644 --- a/ctrd/watch.go +++ b/ctrd/watch.go @@ -62,7 +62,14 @@ func (w *watch) isContainerdDead() bool { // isChannelClosed means containerd break unexpected, all exit channel // ctrd watched will exit. func isChannelClosed(s containerd.ExitStatus) bool { - return s.ExitTime().IsZero() && strings.Contains(s.Error().Error(), "transport is closing") + if s.Error() == nil { + return false + } + + rpcError := strings.Contains(s.Error().Error(), "transport is closing") || + strings.Contains(s.Error().Error(), "rpc error") + + return s.ExitTime().IsZero() && rpcError } func (w *watch) add(ctx context.Context, pack *containerPack) { diff --git a/daemon/daemon.go b/daemon/daemon.go index 19acd8c1e..5afe80a05 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -223,7 +223,7 @@ func (d *Daemon) Run() error { // after initialize network manager, try to recover all // running containers - if err := containerMgr.Restore(ctx); err != nil { + if err := containerMgr.Restore(context.Background()); err != nil { return err }