Skip to content

Conversation

@katarzyna-z
Copy link

This pull request introduces reading of cpuacct.usage_all with unit tests for reading stats from cpuacct cgroup.

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Mar 27, 2020

LGTM, but please squash the commits

Approved with PullApprove

@katarzyna-z katarzyna-z force-pushed the kk-cpuacct-usage-all branch from 74a169c to d74f62e Compare March 30, 2020 07:08
@katarzyna-z
Copy link
Author

@AkihiroSuda I squashed commits

@katarzyna-z katarzyna-z force-pushed the kk-cpuacct-usage-all branch from d74f62e to 935716a Compare March 30, 2020 07:55
@AkihiroSuda
Copy link
Member

CI failing

@iwankgb iwankgb mentioned this pull request Mar 30, 2020
@katarzyna-z katarzyna-z force-pushed the kk-cpuacct-usage-all branch from 935716a to baba000 Compare March 30, 2020 09:33
@katarzyna-z
Copy link
Author

CI passed thanks to small fix in .travis.yaml (related to #2268)

@AkihiroSuda
Copy link
Member

needs rebase

@katarzyna-z katarzyna-z force-pushed the kk-cpuacct-usage-all branch 2 times, most recently from 5c4986e to f4919ff Compare March 31, 2020 07:16
@AkihiroSuda
Copy link
Member

AkihiroSuda commented Mar 31, 2020

LGTM

Approved with PullApprove

@katarzyna-z
Copy link
Author

@caniszczyk, @crosbymichael, @cyphar, @dqminh, @hqhq, @mrunalp, @rjnagal, @vmarmol
Could you take a look on this pull request?

Copy link
Member

@cyphar cyphar left a 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.

return err
}

PercpuUsageInKernelmode, PercpuUsageInUsermode, err := getPercpuUsageInModes(path)
Copy link
Member

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.


func getPercpuUsageInModes(path string) ([]uint64, []uint64, error) {
percpuUsageKernelMode := []uint64{}
percpuUsageUserMode := []uint64{}
Copy link
Member

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"`
Copy link
Member

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.

@katarzyna-z katarzyna-z force-pushed the kk-cpuacct-usage-all branch from f4919ff to 685ba13 Compare April 7, 2020 14:00
@katarzyna-z
Copy link
Author

@cyphar I applied your suggestions.

@katarzyna-z katarzyna-z force-pushed the kk-cpuacct-usage-all branch from 685ba13 to 0037985 Compare April 15, 2020 13:09
@katarzyna-z
Copy link
Author

@AkihiroSuda @cyphar Could you make the 2nd review? I applied all suggestions.

@katarzyna-z
Copy link
Author

katarzyna-z commented Apr 20, 2020

@caniszczyk, @crosbymichael, @cyphar, @dqminh, @hqhq, @mrunalp, @rjnagal, @vmarmol @AkihiroSuda
Could you make the 2nd review of this pull request?
I want to extend metrics in cAdvisor by information from cpuacct.usage_all and this blocks me because cAdvisor uses packages from runc to read cgroups.

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Apr 20, 2020

LGTM

Approved with PullApprove

scanner.Scan() //skipping header line

for scanner.Scan() {
lineFields := strings.SplitN(scanner.Text(), " ", cuacctUsageAllColumnsNumber)
Copy link
Contributor

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.

Copy link
Author

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 {
Copy link
Contributor

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).

Copy link
Contributor

@kolyshkin kolyshkin left a 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.

@katarzyna-z katarzyna-z force-pushed the kk-cpuacct-usage-all branch from 0037985 to 34982ec Compare April 21, 2020 12:14
@katarzyna-z
Copy link
Author

@kolyshkin I addressed your suggestions, please check if I understood you correctly.

@katarzyna-z
Copy link
Author

@kolyshkin Could you take a look at this once again?

@katarzyna-z
Copy link
Author

@AkihiroSuda, @caniszczyk, @crosbymichael, @cyphar, @dqminh, @hqhq, @kolyshkin, @mrunalp
please take another look

@kolyshkin
Copy link
Contributor

kolyshkin commented Apr 29, 2020

LGTM

Approved with PullApprove

@h-vetinari h-vetinari mentioned this pull request Apr 29, 2020
Remove logrus logs from tests

Signed-off-by: Katarzyna Kujawa <[email protected]>
@katarzyna-z katarzyna-z force-pushed the kk-cpuacct-usage-all branch from 34982ec to 407e9f9 Compare May 5, 2020 07:39
@katarzyna-z
Copy link
Author

@AkihiroSuda @kolyshkin please take another look, I resolved a conflict which appeared after merge of #2377

@katarzyna-z
Copy link
Author

@AkihiroSuda @kolyshkin PTAL

@AkihiroSuda
Copy link
Member

AkihiroSuda commented May 7, 2020

LGTM

Approved with PullApprove

@AkihiroSuda
Copy link
Member

@kolyshkin Still LGTY?

@kolyshkin
Copy link
Contributor

kolyshkin commented May 13, 2020

LGTM

Approved with PullApprove

@kolyshkin kolyshkin merged commit 4185531 into opencontainers:master May 13, 2020
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

Successfully merging this pull request may close these issues.

4 participants