diff --git a/cgroup/cgroup.go b/cgroup/cgroup.go index 1dd1df5..48dff4e 100644 --- a/cgroup/cgroup.go +++ b/cgroup/cgroup.go @@ -23,7 +23,7 @@ var ( crioIdRegexp = regexp.MustCompile(`crio-([a-z0-9]{64})`) containerdIdRegexp = regexp.MustCompile(`cri-containerd[-:]([a-z0-9]{64})`) lxcIdRegexp = regexp.MustCompile(`/lxc/([^/]+)`) - systemSliceIdRegexp = regexp.MustCompile(`(/(system|runtime|reserved)\.slice/([^/]+))`) + systemSliceIdRegexp = regexp.MustCompile(`(/(system|runtime|reserved|kube|azure)\.slice/([^/]+))`) talosIdRegexp = regexp.MustCompile(`/(system|podruntime)/([^/]+)`) lxcPayloadRegexp = regexp.MustCompile(`/lxc\.payload\.([^/]+)`) ) @@ -193,7 +193,7 @@ func containerByCgroup(cgroupPath string) (ContainerType, string, error) { return ContainerTypeUnknown, "", fmt.Errorf("invalid talos runtime cgroup %s", cgroupPath) } return ContainerTypeTalosRuntime, path.Join("/talos/", matches[2]), nil - case prefix == "system.slice" || prefix == "runtime.slice" || prefix == "reserved.slice": + case prefix == "system.slice" || prefix == "runtime.slice" || prefix == "reserved.slice" || prefix == "kube.slice" || prefix == "azure.slice": matches := systemSliceIdRegexp.FindStringSubmatch(cgroupPath) if matches == nil { return ContainerTypeUnknown, "", fmt.Errorf("invalid systemd cgroup %s", cgroupPath) diff --git a/cgroup/cgroup_test.go b/cgroup/cgroup_test.go index b7adbfc..888d7ac 100644 --- a/cgroup/cgroup_test.go +++ b/cgroup/cgroup_test.go @@ -161,6 +161,16 @@ func TestContainerByCgroup(t *testing.T) { as.Equal("/reserved.slice/kubelet.service", id) as.Nil(err) + typ, id, err = containerByCgroup("/kube.slice/kubelet.service") + as.Equal(typ, ContainerTypeSystemdService) + as.Equal("/kube.slice/kubelet.service", id) + as.Nil(err) + + typ, id, err = containerByCgroup("/azure.slice/walinuxagent.service") + as.Equal(typ, ContainerTypeSystemdService) + as.Equal("/azure.slice/walinuxagent.service", id) + as.Nil(err) + typ, id, err = containerByCgroup("/system.slice/system-postgresql.slice/postgresql@9.4-main.service") as.Equal(typ, ContainerTypeSystemdService) as.Equal("/system.slice/system-postgresql.slice", id)