75 lines
2.5 KiB
Diff
75 lines
2.5 KiB
Diff
|
|
From 869ceecb455640da5e90f7827f75275665e93e95 Mon Sep 17 00:00:00 2001
|
||
|
|
From: jingrui <jingrui@huawei.com>
|
||
|
|
Date: Sat, 23 Feb 2019 15:51:24 +0800
|
||
|
|
Subject: [PATCH 25/27] restore: skip load task in creating
|
||
|
|
|
||
|
|
load task in creating will stuck containerd restore process.
|
||
|
|
|
||
|
|
Change-Id: I2f8b77a88d78597ef2be5122708fc8ab16fad956
|
||
|
|
Signed-off-by: jingrui <jingrui@huawei.com>
|
||
|
|
---
|
||
|
|
runtime/v1/linux/runtime.go | 5 ++---
|
||
|
|
runtime/v1/shim/service.go | 6 ++++++
|
||
|
|
2 files changed, 8 insertions(+), 3 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/runtime/v1/linux/runtime.go b/runtime/v1/linux/runtime.go
|
||
|
|
index add4d52..5647f94 100644
|
||
|
|
--- a/runtime/v1/linux/runtime.go
|
||
|
|
+++ b/runtime/v1/linux/runtime.go
|
||
|
|
@@ -353,7 +353,6 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
id := path.Name()
|
||
|
|
- log.G(ctx).Infof("load-task %s", id)
|
||
|
|
bundle := loadBundle(
|
||
|
|
id,
|
||
|
|
filepath.Join(r.state, ns, id),
|
||
|
|
@@ -361,6 +360,7 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
||
|
|
)
|
||
|
|
ctx = namespaces.WithNamespace(ctx, ns)
|
||
|
|
pid, _ := runc.ReadPidFile(filepath.Join(bundle.path, proc.InitPidFile))
|
||
|
|
+ log.G(ctx).Infof("load-task %s/%s/%s Pid=%d", r.state, ns, id, pid)
|
||
|
|
s, err := bundle.NewShimClient(ctx, ns, ShimConnect(r.config, func() {
|
||
|
|
err := r.cleanupAfterDeadShim(ctx, bundle, ns, id, pid)
|
||
|
|
if err != nil {
|
||
|
|
@@ -426,8 +426,7 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
if pid <= 0 {
|
||
|
|
- _, err := t.DeleteForce(ctx, 0)
|
||
|
|
- log.G(ctx).Warnf("delete force %s Pid=%d error=%v", id, pid, err)
|
||
|
|
+ log.G(ctx).Warnf("skip load task in creating %s", id)
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
if _, err := os.Stat(filepath.Join(bundle.path, proc.InitExit)); err == nil {
|
||
|
|
diff --git a/runtime/v1/shim/service.go b/runtime/v1/shim/service.go
|
||
|
|
index a2eb35b..d7fdcaf 100644
|
||
|
|
--- a/runtime/v1/shim/service.go
|
||
|
|
+++ b/runtime/v1/shim/service.go
|
||
|
|
@@ -26,6 +26,7 @@ import (
|
||
|
|
"os"
|
||
|
|
"path/filepath"
|
||
|
|
"sync"
|
||
|
|
+ "time"
|
||
|
|
|
||
|
|
"github.com/containerd/console"
|
||
|
|
eventstypes "github.com/containerd/containerd/api/events"
|
||
|
|
@@ -140,9 +141,14 @@ func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (_ *
|
||
|
|
rootfs := filepath.Join(r.Bundle, "rootfs")
|
||
|
|
defer func() {
|
||
|
|
if err != nil {
|
||
|
|
+ logrus.Errorf("create init %s failed error=%v", r.ID, err)
|
||
|
|
if err2 := mount.UnmountAll(rootfs, 0); err2 != nil {
|
||
|
|
log.G(ctx).WithError(err2).Warn("Failed to cleanup rootfs mount")
|
||
|
|
}
|
||
|
|
+ go func() {
|
||
|
|
+ time.Sleep(10*time.Second)
|
||
|
|
+ os.Exit(0)
|
||
|
|
+ }()
|
||
|
|
}
|
||
|
|
}()
|
||
|
|
for _, rm := range mounts {
|
||
|
|
--
|
||
|
|
2.7.4.3
|
||
|
|
|