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

Running cgroups stats functionality within k8s #299

Closed
chapmanc opened this issue Jun 27, 2023 · 1 comment
Closed

Running cgroups stats functionality within k8s #299

chapmanc opened this issue Jun 27, 2023 · 1 comment

Comments

@chapmanc
Copy link

I apologize in advance for my lack of knowledge here but I am trying to do a POC to gather stats about a container within the container and was hoping to use this library to do so but looking at the load function it seems to reference that I need a specific cgroup to load:

// Load will load an existing cgroup and allow it to be controlled
// All static path should not include `/sys/fs/cgroup/` prefix, it should start with your own cgroups name
func Load(path Path, opts ...InitOpts) (Cgroup, error) {

Inside my container (vanilla alpine) I have just the running process itself so I assumed I could use the root pid (it is running itself) and start inspecting the stats of the cgroup but this is failing out:

control, err := cgroup1.Load(cgroup1.PidPath(1))
if err != nil {
	logger.Error("error loading cgroup", "error", err)
}
.... 

Error:

2023-06-27T15:36:20.717Z [ERROR] error loading cgroup: error="cgroups: cgroup mountpoint does not exist"

When I inspect the /proc/1/cgroup I see this. Does that mean I can't access the cgroup which I am running in?

# cat /proc/1/cgroup
0::/
@chapmanc
Copy link
Author

For reference it was because I was using cgroup v1 and the kernel was v2

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