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

return code changed to ErrNotExist #1190

Closed

Conversation

kunalkushwaha
Copy link

getBlkioStat was returning nil instead of ErrNotExist,
if any file in /sys/fs/cgroup/blkio/ was not found.

Correcting this error also, force to fix test cases,
which were not verifying if the files were really missing.

Signed-off-by: Kunal Kushwaha kushwaha_kunal_v7@lab.ntt.co.jp

@kunalkushwaha
Copy link
Author

This PR is part of fix for #487

@hqhq
Copy link
Contributor

hqhq commented Nov 17, 2016

Rejected.

This is not right, some files' absence is totally legal, such as different kernel configurations, for blkio, some files could only be seem on CFQ enabled kernels, so you can't just return error for not finding some files. Some subsystems don't have this issue, so we are having this inconsistency issue.

This PR doesn't look good to me, but I don't deny there can be some improvements to soften this issue, so #486 could still be valid. You'll be welcome to keep digging on this, and thanks for your contribution :) .

Rejected with PullApprove

@kunalkushwaha
Copy link
Author

some files' absence is totally legal, such as different kernel configurations, for blkio, some
files could only be seem on CFQ enabled kernels, so you can't just return error for not finding some files. Some subsystems don't have this issue, so we are having this inconsistency issue.

I Agree. The GetStats() function already take cares about CFQ enabled/disabled configuration.

My fix simply checks, if CFQ enabled, then in case some files are missing, it reports ErrNotExist . Modification is done in getBlkioStat() which is not exposed outside this package.

@hqhq
Copy link
Contributor

hqhq commented Nov 18, 2016

I Agree. The GetStats() function already take cares about CFQ enabled/disabled configuration.

Your PR will break CFQ enabled/disabled check. Fix that could make this PR reasonable.

getBlkioStat was returning nil instead of ErrNotExist,
if any file in /sys/fs/cgroup/blkio/ was not found.

Correcting this error also, force to fix test cases,
which were not verifying if the files were really missing.

Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
@kunalkushwaha
Copy link
Author

@hqhq I have added a new function isCFQEnabled() to check if *_recursive attributes are present.
Please let me know, if you find this solution better?

Also, I found, in BlkioStats there were no entries for blkio.throttle.io_service_bytes and blkio.throttle.io_serviced which were making two test invalid. I also fixed that in this PR.

@@ -79,6 +79,8 @@ type BlkioStats struct {
IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive,omitempty"`
IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive,omitempty"`
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive,omitempty"`
ThrottleServiceBytes []BlkioStatEntry `json:"io_service_bytes,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer the name to be ThrottleIoServiceBytes (and I'd expect we have a follow up PR to s/Io/IO for all blkio entry names to keep consistency with other places) and json name to be throttle_io_service_bytes, and I think adding these two new fields should be in a separated commit.

Same with ThrottleServiced.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for review comments. Will Incorporate this.

@@ -226,12 +230,15 @@ func getStats(path string, stats *cgroups.Stats) error {
if blkioStats, err = getBlkioStat(filepath.Join(path, "blkio.throttle.io_service_bytes")); err != nil {
return err
}
stats.BlkioStats.IoServiceBytesRecursive = blkioStats
// stats.BlkioStats.IoServiceBytesRecursive = blkioStats
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just delete this.

Copy link
Contributor

Choose a reason for hiding this comment

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

After a second thought, I think we might reuse IoServiceBytesRecursive for some reasons, it's been there since the old libcontainer days, maybe upper level monitor tools don't have to care if bandwidth or throttle is used by blkio. And your change will break these tools.

Copy link
Contributor

Choose a reason for hiding this comment

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

I digged a bit and found the PR added this code: docker-archive/libcontainer#167

Looks like it's intentional.

Copy link
Author

Choose a reason for hiding this comment

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

Actually, while testing my code I realized testcase TestNonCFQBlkioStats doesn’t executes for non-CFQ condition as blkio.io_serviced_recursive attribute is present. As result, It always executes CFQ case only.

If some tools depends on IoServiceBytesRecursive and do not honour ThrottleIoServiceBytes , I can re-test the results with them.


if blkioStats, err = getBlkioStat(filepath.Join(path, "blkio.throttle.io_serviced")); err != nil {
return err
}
stats.BlkioStats.IoServicedRecursive = blkioStats
// stats.BlkioStats.IoServicedRecursive = blkioStats
Copy link
Contributor

Choose a reason for hiding this comment

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

And this.

@crosbymichael
Copy link
Member

Feel free to update and reopen if you still think this PR should get in and you have time.

Thanks!

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.

None yet

3 participants