prefer /init.scope/system.slice over /system.slice; fixes #797
Costa Tsaousis committed
Aug 21, 2016 at 13:51 UTC
ec243f6b99c30f19c79fd62e07c36c278192b85a
1 file changed
+16
-5
src/sys_fs_cgroup.c
+16
-5
@@ -707,11 +707,22 @@ struct cgroup *cgroup_add(const char *id) {
707
snprintfz(option, FILENAME_MAX, "enable cgroup %s", cg->chart_title);
708
cg->enabled = config_get_boolean("plugin:cgroups", option, def);
709
710
- struct cgroup *t;
711
- for(t = cgroup_root; t ; t = t->next) {
712
- if(t != cg && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id) && t->enabled) {
713
- error("Control group with chart id '%s' already exists and is enabled. Disabling cgroup '%s'.", cg->chart_id, cg->id);
714
- cg->enabled = 0;
710
+ if(cg->enabled) {
711
+ struct cgroup *t;
712
+ for (t = cgroup_root; t; t = t->next) {
713
+ if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
714
+ if (!strncmp(t->chart_id, "/system.slice/", 14) && !strncmp(cg->chart_id, "/init.scope/system.slice/", 25)) {
715
+ error("Control group with chart id '%s' already exists with id '%s' and is enabled. Swapping them by enabling cgroup with id '%s' and disabling cgroup with id '%s'.",
716
+ cg->chart_id, t->id, cg->id, t->id);
717
+ t->enabled = 0;
718
+ } else {
719
+ error("Control group with chart id '%s' already exists with id '%s' and is enabled. Disabling cgroup with id '%s'.",
720
+ cg->chart_id, t->id, cg->id);
721
+ cg->enabled = 0;
722
+ }
723
+
724
+ break;
725
+ }
726
}
727
}
728