Skip to content

Commit 5f605f5

Browse files
authored
Merge pull request #264 from coroot/issue_214
recognize `kube.slice` and `azure.slice` as systemd services
2 parents bb2721d + 61b0744 commit 5f605f5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cgroup/cgroup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var (
2323
crioIdRegexp = regexp.MustCompile(`crio-([a-z0-9]{64})`)
2424
containerdIdRegexp = regexp.MustCompile(`cri-containerd[-:]([a-z0-9]{64})`)
2525
lxcIdRegexp = regexp.MustCompile(`/lxc/([^/]+)`)
26-
systemSliceIdRegexp = regexp.MustCompile(`(/(system|runtime|reserved)\.slice/([^/]+))`)
26+
systemSliceIdRegexp = regexp.MustCompile(`(/(system|runtime|reserved|kube|azure)\.slice/([^/]+))`)
2727
talosIdRegexp = regexp.MustCompile(`/(system|podruntime)/([^/]+)`)
2828
lxcPayloadRegexp = regexp.MustCompile(`/lxc\.payload\.([^/]+)`)
2929
)
@@ -193,7 +193,7 @@ func containerByCgroup(cgroupPath string) (ContainerType, string, error) {
193193
return ContainerTypeUnknown, "", fmt.Errorf("invalid talos runtime cgroup %s", cgroupPath)
194194
}
195195
return ContainerTypeTalosRuntime, path.Join("/talos/", matches[2]), nil
196-
case prefix == "system.slice" || prefix == "runtime.slice" || prefix == "reserved.slice":
196+
case prefix == "system.slice" || prefix == "runtime.slice" || prefix == "reserved.slice" || prefix == "kube.slice" || prefix == "azure.slice":
197197
matches := systemSliceIdRegexp.FindStringSubmatch(cgroupPath)
198198
if matches == nil {
199199
return ContainerTypeUnknown, "", fmt.Errorf("invalid systemd cgroup %s", cgroupPath)

cgroup/cgroup_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ func TestContainerByCgroup(t *testing.T) {
161161
as.Equal("/reserved.slice/kubelet.service", id)
162162
as.Nil(err)
163163

164+
typ, id, err = containerByCgroup("/kube.slice/kubelet.service")
165+
as.Equal(typ, ContainerTypeSystemdService)
166+
as.Equal("/kube.slice/kubelet.service", id)
167+
as.Nil(err)
168+
169+
typ, id, err = containerByCgroup("/azure.slice/walinuxagent.service")
170+
as.Equal(typ, ContainerTypeSystemdService)
171+
as.Equal("/azure.slice/walinuxagent.service", id)
172+
as.Nil(err)
173+
164174
typ, id, err = containerByCgroup("/system.slice/system-postgresql.slice/postgresql@9.4-main.service")
165175
as.Equal(typ, ContainerTypeSystemdService)
166176
as.Equal("/system.slice/system-postgresql.slice", id)

0 commit comments

Comments
 (0)