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

blkiodev: limit blkio device's read/write Bps/IOps #2563

Closed
wants to merge 1 commit into from

Conversation

houstar
Copy link
Contributor

@houstar houstar commented Dec 15, 2018

Signed-off-by: Leno Hou lenohou@gmail.com

Ⅰ. Describe what this PR did

  1. blkiodev: limit blkio device's read/write Bps/IOps
  2. testcase: add blkio device bps/iops testcase

Ⅱ. Does this pull request fix one issue?

fix #2509

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

To be added later

Ⅳ. Describe how to verify it

Create Container with:

  1. pouch run -it --device /dev/sda:/dev/sda --device-read-bps=/dev/sda:100M busybox sh
  2. Check inside Container's Cgroup filesystem
    #cat /sys/fs/cgroup/blkio/blkio.throttle.read_bps_device
    8:0 104857600

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Dec 15, 2018

Codecov Report

Merging #2563 into master will decrease coverage by 0.26%.
The diff coverage is 47.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2563      +/-   ##
==========================================
- Coverage   69.17%   68.91%   -0.27%     
==========================================
  Files         278      278              
  Lines       18623    18659      +36     
==========================================
- Hits        12883    12859      -24     
- Misses       4268     4310      +42     
- Partials     1472     1490      +18
Flag Coverage Δ
#criv1alpha1test 31.26% <0%> (-0.02%) ⬇️
#criv1alpha2test 35.42% <0%> (-0.07%) ⬇️
#integrationtest 40.53% <47.22%> (-0.14%) ⬇️
#nodee2etest 32.47% <0%> (-0.19%) ⬇️
#unittest 26.7% <0%> (-0.06%) ⬇️
Impacted Files Coverage Δ
ctrd/utils.go 82.97% <44.82%> (-17.03%) ⬇️
daemon/mgr/container.go 58.29% <57.14%> (-0.71%) ⬇️
cri/ocicni/cni_manager.go 58.82% <0%> (-11.77%) ⬇️
daemon/mgr/system.go 67.93% <0%> (-5.35%) ⬇️
ctrd/watch.go 80.28% <0%> (-4.23%) ⬇️
daemon/mgr/events.go 96.29% <0%> (-3.71%) ⬇️
ctrd/client.go 66.92% <0%> (-2.31%) ⬇️
ctrd/image.go 76.75% <0%> (-2.2%) ⬇️
ctrd/container.go 58.01% <0%> (-0.8%) ⬇️
daemon/mgr/container_utils.go 83.33% <0%> (-0.6%) ⬇️
... and 2 more

@houstar houstar force-pushed the blkio-quota branch 3 times, most recently from 2c30f10 to 3ee9e7d Compare December 16, 2018 02:18
apis/types/auth_config.go Outdated Show resolved Hide resolved
apis/swagger.yml Outdated Show resolved Hide resolved
cli/update.go Outdated Show resolved Hide resolved
cli/update.go Outdated Show resolved Hide resolved
cli/update.go Outdated Show resolved Hide resolved
cli/update.go Outdated Show resolved Hide resolved
@allencloud
Copy link
Collaborator

I am afraid that we must add integration test case for this pull request. @houstar 😄

@houstar
Copy link
Contributor Author

houstar commented Dec 17, 2018

I am afraid that we must add integration test case for this pull request. @houstar 😄

OK. I'll update the unit test later

@@ -122,7 +122,7 @@ type Resources struct {
// Total memory limit (memory + swap). Set as `-1` to enable unlimited swap.
MemorySwap int64 `json:"MemorySwap"`

// Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
// Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. -1 is also accepted, as a legacy alias of 0.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch. I am afraid the added sentence is due to #2474.
While I have no idea why pr #2474 has not update this file? @zhuangqh

Copy link
Contributor

Choose a reason for hiding this comment

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

yep...

@allencloud
Copy link
Collaborator

Could you add some TestUpdateSuite test case in file test/cli_update_test.go? Thanks a lot. @houstar

@houstar
Copy link
Contributor Author

houstar commented Dec 17, 2018

Could you add some TestUpdateSuite test case in file test/cli_update_test.go? Thanks a lot. @houstar

@allencloud OK. Will be update at tomorrow

@houstar
Copy link
Contributor Author

houstar commented Dec 18, 2018

@allencloud

  1. I'm afraid to mis-understand that the pouch update and pouch run has same code path.
    so I removed the testcase I've wrote inside test/cli_run_blkio_test.go

  2. This patch will update the container metadata and send these contents to RUNC runtime but runc
    don't support update blkio write/read bps/iops. So the updated Container configuration will not make sense immediately as same as RestartPolicy now.
    https://github.com/opencontainers/runc/blob/master/update.go#L251-L265:

		// Update the value
		config.Cgroups.Resources.BlkioWeight = *r.BlockIO.Weight
		config.Cgroups.Resources.CpuPeriod = *r.CPU.Period
		config.Cgroups.Resources.CpuQuota = *r.CPU.Quota
		config.Cgroups.Resources.CpuShares = *r.CPU.Shares
		config.Cgroups.Resources.CpuRtPeriod = *r.CPU.RealtimePeriod
		config.Cgroups.Resources.CpuRtRuntime = *r.CPU.RealtimeRuntime
		config.Cgroups.Resources.CpusetCpus = r.CPU.Cpus
		config.Cgroups.Resources.CpusetMems = r.CPU.Mems
		config.Cgroups.Resources.KernelMemory = *r.Memory.Kernel
		config.Cgroups.Resources.KernelMemoryTCP = *r.Memory.KernelTCP
		config.Cgroups.Resources.Memory = *r.Memory.Limit
		config.Cgroups.Resources.MemoryReservation = *r.Memory.Reservation
		config.Cgroups.Resources.MemorySwap = *r.Memory.Swap
		config.Cgroups.Resources.PidsLimit = r.Pids.Limit

@zjumoon01
Copy link
Contributor

2. This patch will update the container metadata and send these contents to RUNC runtime but runc
don't support update blkio write/read bps/iops. So the updated Container configuration will not make sense immediately as same as RestartPolicy now.

Yes, runc should update its resource.BlockIO. I'm coding in runc now and will push it in few days.

@pouchrobot
Copy link
Collaborator

ping @houstar
Conflict happens after merging a previous commit.
Please rebase the branch against master and push it back again. Thanks a lot.

@houstar
Copy link
Contributor Author

houstar commented Feb 19, 2019

Close this PR since this was resolved.

@houstar houstar closed this Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] Support update container's device io limit
6 participants