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

Add support to disable diskIO metrics #2103

Merged
merged 1 commit into from
Jan 15, 2019

Conversation

WanLinghao
Copy link
Contributor

@WanLinghao WanLinghao commented Nov 22, 2018

Add support to disable diskIO metrics
ref:#2045

@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@WanLinghao
Copy link
Contributor Author

@dashpole @SamSaffron PTAL

@WanLinghao
Copy link
Contributor Author

/test pull-cadvisor-e2e

@WanLinghao
Copy link
Contributor Author

/test cla/google

@WanLinghao
Copy link
Contributor Author

/retest

@WanLinghao
Copy link
Contributor Author

I signed it!

1 similar comment
@WanLinghao
Copy link
Contributor Author

I signed it!

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@WanLinghao
Copy link
Contributor Author

@dashpole CLA cert has been fixed, PTAL

Copy link
Collaborator

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a great change to make. Just a couple comments

@@ -117,7 +120,8 @@ func (self *rawContainerHandler) Cleanup() {}

func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) {
const hasNetwork = false
hasFilesystem := isRootCgroup(self.name) || len(self.externalMounts) > 0
hasFilesystem := (isRootCgroup(self.name) || len(self.externalMounts) > 0) &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this fixing? It isn't related to diskIO AFAICT

Copy link
Contributor Author

@WanLinghao WanLinghao Jan 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a DiskUsageMetrics bug that people will see has_filesystem be true even they disable disk metrics. I will extract it and launch a new patch later if what I thought is correct @dashpole

@@ -258,6 +258,13 @@ func assignDeviceNamesToPerDiskStats(namer DeviceNamer, diskStats ...[]info.PerD
}
}

// FilterCgroupPaths delete cgroup paths which we do't need base on includeMetrics
func FilterCgroupPaths(cgroups map[string]string, includedMetrics container.MetricSet) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than filtering out afterwards, I think it would be cleaner to do this when we first get the list of cgroup subsystems: https://github.com/google/cadvisor/blob/master/container/libcontainer/helpers.go#L37.

@@ -258,6 +258,13 @@ func assignDeviceNamesToPerDiskStats(namer DeviceNamer, diskStats ...[]info.PerD
}
}

// FilterCgroupPaths delete cgroup paths which we do't need base on includeMetrics
func FilterCgroupPaths(cgroups map[string]string, includedMetrics container.MetricSet) {
if !includedMetrics.Has(container.DiskIOMetrics) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't currently do this for other ignored metrics. What is the benefit of removing the blkio cgroup from the list of cgroups?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, if we don't remove the blkio cgroup, it would keep extracting data from /sys/fs/cgroup/blkio/(ref:

func getBlkioStat(path string) ([]cgroups.BlkioStatEntry, error) {
). And the data it extracted would be just dropped cause we have disabled the diskIO metrics. So here I am trying to do is avoiding useless IO request when diskIO was disabled.

@@ -599,14 +600,16 @@ func setNetworkStats(libcontainerStats *libcontainer.Stats, ret *info.ContainerS
}
}

func newContainerStats(libcontainerStats *libcontainer.Stats, withPerCPU bool) *info.ContainerStats {
func newContainerStats(libcontainerStats *libcontainer.Stats, withPerCPU, withDiskIO bool) *info.ContainerStats {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we are passing in two of these, I would rather just pass ignoreMetrics to the function.

@WanLinghao
Copy link
Contributor Author

@dashpole All comments addressed, PTAL

@@ -117,7 +119,7 @@ func (self *rawContainerHandler) Cleanup() {}

func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) {
const hasNetwork = false
hasFilesystem := isRootCgroup(self.name) || len(self.externalMounts) > 0
hasFilesystem := (isRootCgroup(self.name) || len(self.externalMounts) > 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove extra parenthesis

Copy link
Collaborator

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good after the nit

@WanLinghao
Copy link
Contributor Author

comments addressed @dashpole

@dashpole dashpole merged commit 8240c4a into google:master Jan 15, 2019
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.

3 participants