-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add ability to get individual controller stats #53
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
base: main
Are you sure you want to change the base?
Conversation
f8a0dd5 to
7c07d8a
Compare
|
Hi @kolyshkin |
|
Hi @haircommander |
|
would love to see some unit tests, and maybe even a POC of it being used in an end user project like CRI-O |
I have added the unit tests
I'm not very familiar with codebase of CRI-O, but I can get a quick POC in |
9a446c9 to
3bc182c
Compare
|
LGTM thank you! |
|
@haircommander metrics output |
|
great thanks! cc @kolyshkin @AkihiroSuda @dims @dgrisonnet |
be7f526 to
a8d3912
Compare
e9a61a9 to
5a20778
Compare
|
I updated the poc sambhav-jain-16/cadvisor#3 and CI is green with integration tests and unit tests |
This adds methods to retrieve statistics for individual cgroup controllers (CPU, memory, pids, IO, hugetlb, rdma, misc) instead of requiring all stats to be fetched at once. This enables tools like cadvisor to collect specific metrics with different housekeeping intervals, reducing computational overhead. Fixes: opencontainers#44 Signed-off-by: Sambhav Jain <jnsmbhv@gmail.com>
kolyshkin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to send the review comments. PTAL @sambhav-jain-16
| func (m *LegacyManager) Stats(opts *cgroups.StatsOptions) (*cgroups.Stats, error) { | ||
| m.mu.Lock() | ||
| defer m.mu.Unlock() | ||
|
|
||
| // Default: query all controllers (same as original GetStats behavior) | ||
| controllers := cgroups.AllControllers | ||
| if opts != nil && opts.Controllers != 0 { | ||
| controllers = opts.Controllers | ||
| } | ||
|
|
||
| stats := cgroups.NewStats() | ||
| for _, sys := range legacySubsystems { | ||
| path := m.paths[sys.Name()] | ||
| if path == "" { | ||
| continue | ||
| } | ||
|
|
||
| // Filter based on controller type | ||
| if sys.ID()&controllers == 0 { | ||
| continue | ||
| } | ||
|
|
||
| if err := sys.GetStats(path, stats); err != nil { | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather replace all this with something like
fsMgr, err := fs.NewManager(m.cgroups, m.paths)
if err != nil {
return nil, err
}
return fsMgr.Stats(opts)(unless I'm missing something)
| // String returns the controller name. | ||
| func (c Controller) String() string { | ||
| switch c { | ||
| case CPU: | ||
| return "cpu" | ||
| case Memory: | ||
| return "memory" | ||
| case Pids: | ||
| return "pids" | ||
| case IO: | ||
| return "io" | ||
| case HugeTLB: | ||
| return "hugetlb" | ||
| case RDMA: | ||
| return "rdma" | ||
| case Misc: | ||
| return "misc" | ||
| case CPUSet: | ||
| return "cpuset" | ||
| default: | ||
| panic("unknown controller") | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this?
This PR aims to add methods to retrieve statistics for individual cgroup controllers
(CPU, memory, pids, IO, hugetlb, rdma, misc) instead of requiring all
stats to be fetched at once.
Fixes: #44