summaryrefslogtreecommitdiffstats
path: root/collectors/cgroups.plugin/sys_fs_cgroup.c
diff options
context:
space:
mode:
authorChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-03-13 12:47:20 +0100
committerGitHub <noreply@github.com>2019-03-13 12:47:20 +0100
commitb7998ec82d579bd0550e23f880decdcee61264f5 (patch)
tree834bb528d86c9cff943fe33220952de4cbceca8b /collectors/cgroups.plugin/sys_fs_cgroup.c
parent97699c5c60342be372d776da4829167adfdfc133 (diff)
When running from within a k8s pod, use the k8s API to get the cgroup name (#5576)
* When running from within a k8s pod, use the k8s API to get the pod name * Check the last part of an underscore-delimited or slash-delimited container id * Add a docker image builder that adds a single image to a user-specified registry, for use in k8s * When running in k8s, disable cgroups that the pod API does not return * Use longer name for k8s containers * Add reference to build-test.sh to packaging/docker/README.md * Anonymous statistics should not break when /proc/1/sched is not available
Diffstat (limited to 'collectors/cgroups.plugin/sys_fs_cgroup.c')
-rw-r--r--collectors/cgroups.plugin/sys_fs_cgroup.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c
index 41079a43b4..66dfc2d6aa 100644
--- a/collectors/cgroups.plugin/sys_fs_cgroup.c
+++ b/collectors/cgroups.plugin/sys_fs_cgroup.c
@@ -893,7 +893,7 @@ static inline void cgroup_get_chart_name(struct cgroup *cg) {
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);
+ debug(D_CGROUP, "executing command \"%s\" for cgroup '%s'", command, cg->chart_id);
FILE *fp = mypopen(command, &cgroup_pid);
if(fp) {
// debug(D_CGROUP, "reading from command '%s' for cgroup '%s'", command, cg->id);
@@ -904,12 +904,16 @@ static inline void cgroup_get_chart_name(struct cgroup *cg) {
// debug(D_CGROUP, "closed command for cgroup '%s'", cg->id);
if(s && *s && *s != '\n') {
- debug(D_CGROUP, "cgroup '%s' should be renamed to '%s'", cg->id, s);
+ debug(D_CGROUP, "cgroup '%s' should be renamed to '%s'", cg->chart_id, s);
s = trim(s);
if (s) {
- if(likely(!name_error))
+ if(likely(name_error==0))
cg->pending_renames = 0;
+ else if (unlikely(name_error==3)) {
+ debug(D_CGROUP, "cgroup '%s' disabled based due to rename command output", cg->chart_id);
+ cg->enabled = 0;
+ }
if(likely(cg->pending_renames < 2)) {
freez(cg->chart_title);