Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in cgroups renaming #5612

Merged
merged 1 commit into from Mar 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions collectors/cgroups.plugin/sys_fs_cgroup.c
Expand Up @@ -888,7 +888,7 @@ static inline void cgroup_get_chart_name(struct cgroup *cg) {
pid_t cgroup_pid;
char command[CGROUP_CHARTID_LINE_MAX + 1];

snprintfz(command, CGROUP_CHARTID_LINE_MAX, "exec %s '%s'", cgroups_rename_script, cg->id);
snprintfz(command, CGROUP_CHARTID_LINE_MAX, "exec %s '%s'", cgroups_rename_script, cg->chart_id);

debug(D_CGROUP, "executing command \"%s\" for cgroup '%s'", command, cg->id);
FILE *fp = mypopen(command, &cgroup_pid);
Expand All @@ -908,12 +908,14 @@ static inline void cgroup_get_chart_name(struct cgroup *cg) {
if(likely(!name_error))
cg->pending_renames = 0;

freez(cg->chart_title);
cg->chart_title = cgroup_title_strdupz(s);
if(likely(cg->pending_renames < 2)) {
cakrit marked this conversation as resolved.
Show resolved Hide resolved
freez(cg->chart_title);
cg->chart_title = cgroup_title_strdupz(s);

freez(cg->chart_id);
cg->chart_id = cgroup_chart_id_strdupz(s);
cg->hash_chart = simple_hash(cg->chart_id);
freez(cg->chart_id);
cg->chart_id = cgroup_chart_id_strdupz(s);
cg->hash_chart = simple_hash(cg->chart_id);
}
}
}
}
Expand Down