Skip to content

Commit 75b6cfb

Browse files
committed
process_metrics_linux.go: make sure that getCgroupV2Path() returns a path, which doesnt end with a slash
This avoids double slashes in the constructed cgroup paths like in the comment VictoriaMetrics/VictoriaLogs#517 (comment) .
1 parent 72cbb2f commit 75b6cfb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

process_metrics_linux.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,5 +413,8 @@ func getCgroupV2Path() string {
413413
if len(tmp) != 2 {
414414
return ""
415415
}
416-
return "/sys/fs/cgroup" + strings.TrimSpace(tmp[1])
416+
path := "/sys/fs/cgroup" + strings.TrimSpace(tmp[1])
417+
418+
// Drop trailing slash if it exsits. This prevents from '//' in the constructed paths by the caller.
419+
return strings.TrimSuffix(path, "/")
417420
}

0 commit comments

Comments
 (0)