Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgroup prefix matching for Amazon ECS missing #122

Open
Ristovski opened this issue Sep 5, 2024 · 0 comments
Open

cgroup prefix matching for Amazon ECS missing #122

Ristovski opened this issue Sep 5, 2024 · 0 comments

Comments

@Ristovski
Copy link

When running coroot-node-agent directly on an EC2 instance thats part of an ECS cluster, the following message is spammed:
W0905 11:42:31.320648 1826000 registry.go:305] failed to read proc cgroup: unknown container: /ecstasks.slice/ecstasks-[UID].slice/docker-[UID].scope

This seems to stem from the fact that the prefix matching is hardcoded and doesn't match ecstasks.slice:

if prefix == "user.slice" || prefix == "init.scope" {
return ContainerTypeStandaloneProcess, "", nil
}
if prefix == "docker" || (prefix == "system.slice" && strings.HasPrefix(parts[1], "docker-")) {
matches := dockerIdRegexp.FindStringSubmatch(path)
if matches == nil {
return ContainerTypeUnknown, "", fmt.Errorf("invalid docker cgroup %s", path)
}
return ContainerTypeDocker, matches[1], nil
}
if strings.Contains(path, "kubepods") {
crioMatches := crioIdRegexp.FindStringSubmatch(path)
if crioMatches != nil {
return ContainerTypeCrio, crioMatches[1], nil
}
if strings.Contains(path, "crio-conmon-") {
return ContainerTypeUnknown, "", nil
}
containerdMatches := containerdIdRegexp.FindStringSubmatch(path)
if containerdMatches != nil {
return ContainerTypeContainerd, containerdMatches[1], nil
}
matches := dockerIdRegexp.FindStringSubmatch(path)
if matches == nil {
return ContainerTypeSandbox, "", nil
}
return ContainerTypeDocker, matches[1], nil
}
if prefix == "lxc" {
matches := lxcIdRegexp.FindStringSubmatch(path)
if matches == nil {
return ContainerTypeUnknown, "", fmt.Errorf("invalid lxc cgroup %s", path)
}
return ContainerTypeLxc, matches[1], nil
}
if prefix == "system.slice" || prefix == "runtime.slice" {
matches := systemSliceIdRegexp.FindStringSubmatch(path)
if matches == nil {
return ContainerTypeUnknown, "", fmt.Errorf("invalid systemd cgroup %s", path)
}
return ContainerTypeSystemdService, strings.Replace(matches[1], "\\x2d", "-", -1), nil
}
return ContainerTypeUnknown, "", fmt.Errorf("unknown container: %s", path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant