-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add reading of information from cpuacct.usage_all #2271
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
Add reading of information from cpuacct.usage_all #2271
Conversation
74a169c to
d74f62e
Compare
|
@AkihiroSuda I squashed commits |
d74f62e to
935716a
Compare
|
CI failing |
935716a to
baba000
Compare
|
CI passed thanks to small fix in .travis.yaml (related to #2268) |
|
needs rebase |
5c4986e to
f4919ff
Compare
|
@caniszczyk, @crosbymichael, @cyphar, @dqminh, @hqhq, @mrunalp, @rjnagal, @vmarmol |
cyphar
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.
Just a few nits. Aside from that it looks good.
libcontainer/cgroups/fs/cpuacct.go
Outdated
| return err | ||
| } | ||
|
|
||
| PercpuUsageInKernelmode, PercpuUsageInUsermode, err := getPercpuUsageInModes(path) |
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.
First character should be lowercase in variable names.
libcontainer/cgroups/fs/cpuacct.go
Outdated
|
|
||
| func getPercpuUsageInModes(path string) ([]uint64, []uint64, error) { | ||
| percpuUsageKernelMode := []uint64{} | ||
| percpuUsageUserMode := []uint64{} |
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.
NIT: These names are a bit long given that the function already tells you that it's getting the per-cpu usage information. But I don't mind too much.
types/events.go
Outdated
| Total uint64 `json:"total,omitempty"` | ||
| Percpu []uint64 `json:"percpu,omitempty"` | ||
| PercpuKernel []uint64 `json:"percpuKernel,omitempty"` | ||
| PercpuUser []uint64 `json:"percpuUser,omitempty"` |
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.
These JSON fields should use underscores (percpu_kernel and percpu_user). I know that some others like kernelTCP don't but in theory that's the style for event JSON.
f4919ff to
685ba13
Compare
|
@cyphar I applied your suggestions. |
685ba13 to
0037985
Compare
|
@AkihiroSuda @cyphar Could you make the 2nd review? I applied all suggestions. |
|
@caniszczyk, @crosbymichael, @cyphar, @dqminh, @hqhq, @mrunalp, @rjnagal, @vmarmol @AkihiroSuda |
libcontainer/cgroups/fs/cpuacct.go
Outdated
| scanner.Scan() //skipping header line | ||
|
|
||
| for scanner.Scan() { | ||
| lineFields := strings.SplitN(scanner.Text(), " ", cuacctUsageAllColumnsNumber) |
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.
You probably should have used cuacctUsageAllColumnsNumber + 1 as the last parameter. Otherwise you won't be able to detect a situation when there are extra fields.
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 agree, adding +1 will help if a new column appear.
| } | ||
|
|
||
| func expectCPUUsageEqual(t *testing.T, expected, actual cgroups.CpuUsage) { | ||
| if expected.TotalUsage != actual.TotalUsage { |
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.
Maybe you could just use reflect.DeepEqual here (or directly in the TestCpuacctStats). If there are other places like this, they can be converted to use DeepEqual, too (as a separate preceding patch).
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.
Left a few comments.
0037985 to
34982ec
Compare
|
@kolyshkin I addressed your suggestions, please check if I understood you correctly. |
|
@kolyshkin Could you take a look at this once again? |
|
@AkihiroSuda, @caniszczyk, @crosbymichael, @cyphar, @dqminh, @hqhq, @kolyshkin, @mrunalp |
Remove logrus logs from tests Signed-off-by: Katarzyna Kujawa <[email protected]>
34982ec to
407e9f9
Compare
|
@AkihiroSuda @kolyshkin please take another look, I resolved a conflict which appeared after merge of #2377 |
|
@AkihiroSuda @kolyshkin PTAL |
|
@kolyshkin Still LGTY? |
This pull request introduces reading of cpuacct.usage_all with unit tests for reading stats from cpuacct cgroup.