From 5b2cb5f9f880c89ab3ac7983c0d6afa3643e47ad Mon Sep 17 00:00:00 2001 From: Alexandre Proulx Date: Tue, 3 Mar 2026 00:40:07 +0000 Subject: [PATCH] cgroup: add podruntime.slice to recognized systemd slices --- cgroup/cgroup.go | 4 ++-- cgroup/cgroup_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cgroup/cgroup.go b/cgroup/cgroup.go index 04c95c8..4938886 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|kube|azure)\.slice/([^/]+))`) + systemSliceIdRegexp = regexp.MustCompile(`(/(system|runtime|reserved|kube|azure|podruntime)\.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" || prefix == "kube.slice" || prefix == "azure.slice": + case prefix == "system.slice" || prefix == "runtime.slice" || prefix == "reserved.slice" || prefix == "kube.slice" || prefix == "azure.slice" || prefix == "podruntime.slice": if strings.HasSuffix(cgroupPath, ".scope") { return ContainerTypeStandaloneProcess, "", nil } diff --git a/cgroup/cgroup_test.go b/cgroup/cgroup_test.go index 7e8b7af..4ac82cd 100644 --- a/cgroup/cgroup_test.go +++ b/cgroup/cgroup_test.go @@ -171,6 +171,16 @@ func TestContainerByCgroup(t *testing.T) { as.Equal("/azure.slice/walinuxagent.service", id) as.Nil(err) + typ, id, err = containerByCgroup("/podruntime.slice/containerd.service") + as.Equal(typ, ContainerTypeSystemdService) + as.Equal("/podruntime.slice/containerd.service", id) + as.Nil(err) + + typ, id, err = containerByCgroup("/podruntime.slice/kubelet.service") + as.Equal(typ, ContainerTypeSystemdService) + as.Equal("/podruntime.slice/kubelet.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)