containerd/patch/0071-containerd-fix-containerd-shim-residual-when-kill-co.patch

46 lines
1.7 KiB
Diff
Raw Normal View History

From 5d72fe2c0d6774e94cad6feacec87db703104fe7 Mon Sep 17 00:00:00 2001
From: xiadanni <xiadanni1@huawei.com>
Date: Fri, 19 Feb 2021 16:37:48 +0800
Subject: [PATCH] containerd: fix containerd-shim residual when kill containerd
during starting container
after shim process started, containerd will write shim socket address
to address file, but if containerd is killed before write file, new
containerd process could not get shim socket address, and will not
kill it even if that shim could not work.
so we write address file ahead of starting shim process.
Signed-off-by: xiadanni <xiadanni1@huawei.com>
---
runtime/v1/shim/client/client.go | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/runtime/v1/shim/client/client.go b/runtime/v1/shim/client/client.go
index 9e63af4..bc9ac92 100644
--- a/runtime/v1/shim/client/client.go
+++ b/runtime/v1/shim/client/client.go
@@ -92,6 +92,10 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
go io.Copy(os.Stderr, stderrLog)
}
+ if err := writeFile(filepath.Join(config.Path, "address"), address); err != nil {
+ return nil, nil, err
+ }
+
cmd, err := newCommand(binary, daemonAddress, debug, config, f, stdoutLog, stderrLog)
if err != nil {
return nil, nil, err
@@ -122,9 +126,6 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
"debug": debug,
}).Infof("shim %s started", binary)
- if err := writeFile(filepath.Join(config.Path, "address"), address); err != nil {
- return nil, nil, err
- }
if err := writeFile(filepath.Join(config.Path, "shim.pid"), strconv.Itoa(cmd.Process.Pid)); err != nil {
return nil, nil, err
}
--
1.8.3.1