lxc/0123-in-accordance-with-hook-spec-in-oci.patch
LiFeng 1e407c11a9 lxc: internal change
Signed-off-by: LiFeng <lifeng68@huawei.com>
2020-03-03 08:56:30 -05:00

82 lines
2.9 KiB
Diff

From b6c3d8631ce628d2f71b4c2ff699c0bdeaed97a8 Mon Sep 17 00:00:00 2001
From: LiuHao <liuhao27@huawei.com>
Date: Mon, 25 Nov 2019 21:15:40 +0800
Subject: [PATCH 123/140] in accordance with hook spec in oci
Signed-off-by: LiuHao <liuhao27@huawei.com>
---
src/lxc/cgroups/cgfsng.c | 4 ++--
src/lxc/conf.c | 6 +++---
src/lxc/start.c | 14 ++++----------
3 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 7c92abe..87b49b0 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -2013,8 +2013,8 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops, const char *name,
path = lxc_cmd_get_cgroup_path(name, lxcpath, h->controllers[0]);
/* not running */
- if (!path)
- continue;
+ if (path == NULL)
+ return false;
fullpath = build_full_cgpath_from_monitorpath(h, path, "cgroup.procs");
free(path);
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 5fd65e7..21ec340 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -4937,9 +4937,9 @@ static int do_run_oci_hooks(const char *name, const char *lxcpath, struct lxc_co
case OCI_HOOK_POSTSTOP:
for (i = 0; i < lc->ocihooks->poststop_len; i++) {
work_conf.ocihook = lc->ocihooks->poststop[i];
- ret = run_ocihook_script_argv(name, "lxc", &work_conf, lxcpath, rootpath);
- if (ret != 0)
- break;
+ nret = run_ocihook_script_argv(name, "lxc", &work_conf, lxcpath, rootpath);
+ if (nret != 0)
+ WARN("running poststart hook %zu failed, ContainerId: %s", i, name);
}
break;
default:
diff --git a/src/lxc/start.c b/src/lxc/start.c
index c1e0d5d..7246283 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1185,14 +1185,11 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
while (namespace_count--)
free(namespaces[namespace_count]);
- // if we shared pid namespace with others, should kill all processes within container cgroup
- if (handler->conf->ns_share[LXC_NS_PID] != NULL) {
- TRACE("Trying to kill all subprocess");
- signal_all_processes(handler);
- TRACE("Finished kill all subprocess");
- }
retry:
if (!cgroup_ops->destroy(cgroup_ops, handler)) {
+ TRACE("Trying to kill all subprocess");
+ signal_all_processes(handler);
+ TRACE("Finished kill all subprocess");
if (retry_count < max_retry) {
usleep(100 * 1000); /* 100 millisecond */
retry_count++;
@@ -2851,10 +2848,7 @@ int do_lxcapi_clean_resource(char *name, char *lxcpath, struct lxc_conf *conf, p
ret = -1;
goto out;
}
- // if we shared pid namespace with others, should kill all processes within container cgroup
- if (handler->conf->ns_share[LXC_NS_PID] != NULL) {
- signal_all_processes(handler);
- }
+ signal_all_processes(handler);
if (run_oci_hooks(handler->name, "oci-poststop", handler->conf, handler->lxcpath)) {
ERROR("Failed to run lxc.hook.post-stop for container \"%s\".", handler->name);
--
1.8.3.1