2020-03-01 22:54:01 -05:00
|
|
|
From 8f8184392cd877ae05e6f02529135b1900424812 Mon Sep 17 00:00:00 2001
|
2020-01-05 22:20:49 -05:00
|
|
|
From: LiFeng <lifeng68@huawei.com>
|
|
|
|
|
Date: Sat, 28 Dec 2019 20:12:57 -0500
|
2020-03-01 22:54:01 -05:00
|
|
|
Subject: [PATCH 136/140] lxc: fix retry bug in cgroup
|
2020-01-05 22:20:49 -05:00
|
|
|
|
|
|
|
|
Signed-off-by: LiFeng <lifeng68@huawei.com>
|
|
|
|
|
---
|
|
|
|
|
src/lxc/cgroups/cgfsng.c | 34 +++++++++++++++++-----------------
|
|
|
|
|
1 file changed, 17 insertions(+), 17 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
|
|
|
|
|
index 9f0bb69..ed08f10 100644
|
|
|
|
|
--- a/src/lxc/cgroups/cgfsng.c
|
|
|
|
|
+++ b/src/lxc/cgroups/cgfsng.c
|
|
|
|
|
@@ -1025,6 +1025,7 @@ __cgfsng_ops static bool cgfsng_payload_create(struct cgroup_ops *ops,
|
|
|
|
|
__cgfsng_ops static bool cgfsng_payload_enter(struct cgroup_ops *ops, pid_t pid)
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
+ char *container_cgroup = ops->container_cgroup;
|
|
|
|
|
char pidstr[INTTYPE_TO_STRLEN(pid_t)];
|
|
|
|
|
|
|
|
|
|
len = snprintf(pidstr, sizeof(pidstr), "%d", pid);
|
|
|
|
|
@@ -1042,14 +1043,13 @@ __cgfsng_ops static bool cgfsng_payload_enter(struct cgroup_ops *ops, pid_t pid)
|
|
|
|
|
retry:
|
|
|
|
|
ret = lxc_write_to_file(fullpath, pidstr, len, false, 0666);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
- if (errno == ENOENT) {
|
|
|
|
|
- if (retry_count < max_retry) {
|
|
|
|
|
- SYSERROR("Failed to enter cgroup \"%s\" with retry count:%d", fullpath, retry_count);
|
|
|
|
|
- (void)mkdir_eexist_on_last(ops->hierarchies[i]->container_full_path, 0755);
|
|
|
|
|
- usleep(100 * 1000); /* 100 millisecond */
|
|
|
|
|
- retry_count++;
|
|
|
|
|
- goto retry;
|
|
|
|
|
- }
|
|
|
|
|
+ if (retry_count < max_retry) {
|
|
|
|
|
+ SYSERROR("Failed to enter cgroup \"%s\" with retry count:%d", fullpath, retry_count);
|
|
|
|
|
+ (void)cg_legacy_handle_cpuset_hierarchy(ops->hierarchies[i], container_cgroup);
|
|
|
|
|
+ (void)mkdir_eexist_on_last(ops->hierarchies[i]->container_full_path, 0755);
|
|
|
|
|
+ usleep(100 * 1000); /* 100 millisecond */
|
|
|
|
|
+ retry_count++;
|
|
|
|
|
+ goto retry;
|
|
|
|
|
}
|
|
|
|
|
SYSERROR("Failed to enter cgroup \"%s\"", fullpath);
|
|
|
|
|
free(fullpath);
|
|
|
|
|
@@ -1949,6 +1949,7 @@ static int cg_legacy_set_data(struct cgroup_ops *ops, const char *filename,
|
|
|
|
|
char *controller = NULL;
|
|
|
|
|
int retry_count = 0;
|
|
|
|
|
int max_retry = 10;
|
|
|
|
|
+ char *container_cgroup = ops->container_cgroup;
|
|
|
|
|
|
|
|
|
|
len = strlen(filename);
|
|
|
|
|
controller = alloca(len + 1);
|
|
|
|
|
@@ -1979,15 +1980,14 @@ static int cg_legacy_set_data(struct cgroup_ops *ops, const char *filename,
|
|
|
|
|
|
|
|
|
|
retry:
|
|
|
|
|
ret = lxc_write_to_file(fullpath, value, strlen(value), false, 0666);
|
|
|
|
|
- if (ret) {
|
|
|
|
|
- if (errno == ENOENT) {
|
|
|
|
|
- if (retry_count < max_retry) {
|
|
|
|
|
- SYSERROR("setting cgroup config for ready process caused \"failed to write %s to %s\".", value, fullpath);
|
|
|
|
|
- (void)mkdir_eexist_on_last(h->container_full_path, 0755);
|
|
|
|
|
- usleep(100 * 1000); /* 100 millisecond */
|
|
|
|
|
- retry_count++;
|
|
|
|
|
- goto retry;
|
|
|
|
|
- }
|
|
|
|
|
+ if (ret != 0) {
|
|
|
|
|
+ if (retry_count < max_retry) {
|
|
|
|
|
+ SYSERROR("setting cgroup config for ready process caused \"failed to write %s to %s\".", value, fullpath);
|
|
|
|
|
+ (void)cg_legacy_handle_cpuset_hierarchy(h, container_cgroup);
|
|
|
|
|
+ (void)mkdir_eexist_on_last(h->container_full_path, 0755);
|
|
|
|
|
+ usleep(100 * 1000); /* 100 millisecond */
|
|
|
|
|
+ retry_count++;
|
|
|
|
|
+ goto retry;
|
|
|
|
|
}
|
|
|
|
|
lxc_write_error_message(ops->errfd,
|
|
|
|
|
"%s:%d: setting cgroup config for ready process caused \"failed to write %s to %s: %s\".",
|
|
|
|
|
--
|
|
|
|
|
1.8.3.1
|
|
|
|
|
|