Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cgroup/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\.([^/]+)`)
)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions cgroup/cgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]")
as.Equal(typ, ContainerTypeSystemdService)
as.Equal("/system.slice/system-postgresql.slice", id)
Expand Down
Loading