containerd/patch/0041-containerd-fix-containerd-call-runv-delete-directly.patch

81 lines
2.3 KiB
Diff
Raw Normal View History

2019-12-30 12:24:38 +08:00
From be9c04e9a90be92437c12ce90c8ff6d4ec1d83b3 Mon Sep 17 00:00:00 2001
From: jiangpengfei <jiangpengfei9@huawei.com>
Date: Thu, 18 Jul 2019 07:57:52 -0400
Subject: [PATCH] containerd: fix containerd call runv delete directly
use wrong --root parameters
reason: When containerd-shim process is killed abnormaly, containerd will exec runv
delete command directly, however it will use the wrong --root parameters which is not
compatible with runv runtime.
Signed-off-by: jiangpengfei <jiangpengfei9@huawei.com>
---
runtime/v1/linux/proc/init.go | 4 ++--
runtime/v1/linux/runtime.go | 10 +++++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/runtime/v1/linux/proc/init.go b/runtime/v1/linux/proc/init.go
index d464147..44d3f58 100644
--- a/runtime/v1/linux/proc/init.go
+++ b/runtime/v1/linux/proc/init.go
@@ -45,7 +45,7 @@ import (
const InitPidFile = "init.pid"
// Default runv runtime root dir
-const defaultRunvRoot = "/run/runv"
+const DefaultRunvRoot = "/run/runv"
// Init represents an initial process for a container
type Init struct {
@@ -89,7 +89,7 @@ func NewRunc(root, path, namespace, runtime, criu string, systemd bool) *runc.Ru
rootPath := filepath.Join(root, namespace)
if strings.Contains(runtime, "runv") {
- rootPath = defaultRunvRoot
+ rootPath = DefaultRunvRoot
}
return &runc.Runc{
diff --git a/runtime/v1/linux/runtime.go b/runtime/v1/linux/runtime.go
index 66914fe..f8e3074 100644
--- a/runtime/v1/linux/runtime.go
+++ b/runtime/v1/linux/runtime.go
@@ -25,6 +25,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strings"
"time"
eventstypes "github.com/containerd/containerd/api/events"
@@ -506,6 +507,7 @@ func (r *Runtime) terminate(ctx context.Context, bundle *bundle, ns, id string)
if err != nil {
return err
}
+
if err := rt.Delete(ctx, id, &runc.DeleteOpts{
Force: true,
}); err != nil {
@@ -539,11 +541,17 @@ func (r *Runtime) getRuntime(ctx context.Context, ns, id string) (*runc.Runc, er
}
}
+ rootPath := filepath.Join(root, ns)
+
+ if strings.Contains(cmd, "runv") {
+ rootPath = proc.DefaultRunvRoot
+ }
+
return &runc.Runc{
Command: cmd,
LogFormat: runc.JSON,
PdeathSignal: unix.SIGKILL,
- Root: filepath.Join(root, ns),
+ Root: rootPath,
Debug: r.config.ShimDebug,
}, nil
}
--
1.8.3.1