when 2 containers have the same name, prefer the new one over the old one, if the old is not available any more; fixes #874
Costa Tsaousis (ktsaou) committed
Sep 2, 2016 at 22:44 UTC
1947daff41f55064e2012be1228f2e668fc9f4a9
1 file changed
+16
-6
src/sys_fs_cgroup.c
+16
-6
@@ -161,8 +161,9 @@ struct cpuacct_usage {
161
};
162
163
struct cgroup {
164
- int available; // found in the filesystem
165
- int enabled; // enabled in the config
164
+ char available; // found in the filesystem
165
+ char last_available; // found in the filesystem the last time
166
+ char enabled; // enabled in the config
167
168
char *id;
169
uint32_t hash;
@@ -716,9 +717,16 @@ struct cgroup *cgroup_add(const char *id) {
717
cg->chart_id, t->id, cg->id, t->id);
718
t->enabled = 0;
719
} 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;
720
+ if(t->last_available) {
721
+ error("Control group with chart id '%s' already exists with id '%s' and is enabled and available. Disabling cgroup with id '%s'.",
722
+ cg->chart_id, t->id, cg->id);
723
+ cg->enabled = 0;
724
+ }
725
+ else {
726
+ error("Control group with chart id '%s' already exists with id '%s' but is not available. Enabling cgroup with id '%s'.",
727
+ cg->chart_id, t->id, cg->id);
728
+ t->enabled = 0;
729
+ }
730
}
731
732
break;
@@ -865,8 +873,10 @@ void mark_all_cgroups_as_not_available() {
873
struct cgroup *cg;
874
875
// mark all as not available
868
- for(cg = cgroup_root; cg ; cg = cg->next)
876
+ for(cg = cgroup_root; cg ; cg = cg->next) {
877
+ cg->last_available = cg->available;
878
cg->available = 0;
879
+ }
880
}
881
882
void cleanup_all_cgroups() {