Skip to content

Commit 9ad681c

Browse files
authored
Allow cgroup paths containing colons (prometheus#354)
Signed-off-by: Evan Lezar <[email protected]>
1 parent bc932d6 commit 9ad681c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

proc_cgroup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type Cgroup struct {
4949
func parseCgroupString(cgroupStr string) (*Cgroup, error) {
5050
var err error
5151

52-
fields := strings.Split(cgroupStr, ":")
52+
fields := strings.SplitN(cgroupStr, ":", 3)
5353
if len(fields) < 3 {
5454
return nil, fmt.Errorf("at least 3 fields required, found %d fields in cgroup string: %s", len(fields), cgroupStr)
5555
}

proc_cgroup_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ func TestParseCgroupString(t *testing.T) {
5656
},
5757
},
5858
{
59-
name: "extra fields (such as those added by later kernel versions)",
60-
s: "0::/:foobar",
59+
name: "path containing colons",
60+
s: "0::/some/long/path:foobar",
6161
shouldErr: false,
6262
cgroup: &Cgroup{
6363
HierarchyID: 0,
6464
Controllers: nil,
65-
Path: "/",
65+
Path: "/some/long/path:foobar",
6666
},
6767
},
6868
{

0 commit comments

Comments
 (0)