Merge pull request #2684 from brauner/2018-10-10/cgfsng_improve_logging

cgfsng: improve deletion and logging
This commit is contained in:
Stéphane Graber 2018-10-09 19:23:55 -04:00 committed by GitHub
commit d523cf5982
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1152,6 +1152,7 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
for (int i = 0; ops->hierarchies[i]; i++) { for (int i = 0; ops->hierarchies[i]; i++) {
int ret; int ret;
char *chop;
struct hierarchy *h = ops->hierarchies[i]; struct hierarchy *h = ops->hierarchies[i];
if (!h->monitor_full_path) if (!h->monitor_full_path)
@ -1169,16 +1170,27 @@ __cgfsng_ops static void cgfsng_monitor_destroy(struct cgroup_ops *ops,
PIVOT_CGROUP, PIVOT_CGROUP,
"cgroup.procs", NULL); "cgroup.procs", NULL);
chop = strrchr(pivot_path, '/');
if (chop)
*chop = '\0';
ret = mkdir_p(pivot_path, 0755); ret = mkdir_p(pivot_path, 0755);
if (ret < 0 && errno != EEXIST) if (ret < 0 && errno != EEXIST) {
SYSWARN("Failed to create cgroup \"%s\"\n", pivot_path);
goto next; goto next;
}
if (chop)
*chop = '/';
/* Move ourselves into the pivot cgroup to delete our own /* Move ourselves into the pivot cgroup to delete our own
* cgroup. * cgroup.
*/ */
ret = lxc_write_to_file(pivot_path, pidstr, len, false, 0666); ret = lxc_write_to_file(pivot_path, pidstr, len, false, 0666);
if (ret != 0) if (ret != 0) {
SYSWARN("Failed to move monitor %s to \"%s\"\n", pidstr, pivot_path);
goto next; goto next;
}
ret = recursive_destroy(h->monitor_full_path); ret = recursive_destroy(h->monitor_full_path);
if (ret < 0) if (ret < 0)