From 94b1e21950631130c86be5572e8a89bd27d373bb Mon Sep 17 00:00:00 2001From: xueshaojia <xueshaojia@huawei.com>Date: 2019年2月14日 10:48:14 +0800Subject: [PATCH] containerd: check shim alive when containerd is restartedreason: When containerd is restarted, it will load all tasks.In some cases, thecontainerd-shim is killed and the sock file will exist for a while.Containerd should check the containerd-shim is available using the sock file.If the containerd-shim server not responses, do r.cleanupAfterDeadShimIf containerd-shim and containerd process is killed, container will exit,however containerd exit event which generates when containerd restart to reloadtasks can not publish to dockerd, because at the time of loading tasks the connectionbetween dockerd and containerd isn't established.So we add this unpublish exit event to file and resend this event after grpc connectionis established.---runtime/v1/linux/runtime.go | 21 +++++++++++++++++++++1 file changed, 21 insertions(+)diff --git a/runtime/v1/linux/runtime.go b/runtime/v1/linux/runtime.goindex a6efd81..544b692 100644--- a/runtime/v1/linux/runtime.go+++ b/runtime/v1/linux/runtime.go@@ -416,6 +416,9 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {"id": id,"namespace": ns,}).Error("connecting to shim")+ if !events.ExitPending(ns, id, uint32(pid)) {+ events.ExitAddFile(ns, events.ExitFile(id, uint32(pid), uint32(events.ExitStatusDefault)), "cleanup dirty task")+ }err := r.cleanupAfterDeadShim(ctx, bundle, ns, id)if err != nil {log.G(ctx).WithError(err).WithField("bundle", bundle.path).@@ -423,6 +426,24 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {}continue}+ ctxContact, cancel := context.WithTimeout(ctx, 5*time.Second)+ defer cancel()+ alive, err := s.IsAlive(ctxContact)+ if !alive {+ log.G(ctx).WithError(err).WithFields(logrus.Fields{+ "id": id,+ "namespace": ns,+ }).Error("contacting to shim")+ if !events.ExitPending(ns, id, uint32(pid)) {+ events.ExitAddFile(ns, events.ExitFile(id, uint32(pid), uint32(events.ExitStatusDefault)), "cleanup dirty task")+ }+ err := r.cleanupAfterDeadShim(ctx, bundle, ns, id, pid)+ if err != nil {+ log.G(ctx).WithError(err).WithField("bundle", bundle.path).+ Error("cleaning up after dead shim")+ }+ continue+ }logDirPath := filepath.Join(r.root, ns, id)--2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型