-
Notifications
You must be signed in to change notification settings - Fork 644
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 for remaining blkio settings #3950
base: main
Are you sure you want to change the base?
Conversation
45a457d
to
ef71f08
Compare
Test failures do not appear to be related to the specific change. Previous runs have already passed those checks. |
ef71f08
to
39f89b3
Compare
|
||
func TestRunBlkioSettingCgroupV2(t *testing.T) { | ||
t.Parallel() | ||
testutil.DockerIncompatible(t) |
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.
why is this docker imcompatible?
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.
The current test validation uses the created container's runtime spec to check for the specified values to be present. Calling containerd's socket is not support when running with Docker.
I think I can achieve the same by using container inspect instead, but need to populate the inspect response. I can add that in the next revision.
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 have made the change to use inspect so the test can work with both nerdctl and docker. However, while investigating the docker failure, I found another issue related to a bug in docker cli docker/cli#5321. Some of the blkio options are broken in docker v26.0.1 <-> v27.1.1. The fix has been merged and backported to all branches, however the docker cli version available in the runner does not have the fix yet.
I have decided to temporarily disable the specific options test for docker. We can re-enable them once we have a newer docker cli version available. On another note, we can decide to use a specific(newer) version of docker clifor the integration tests. However, I think that is beyond the scope of this PR.
switch info.CgroupDriver { | ||
case "none", "": | ||
t.Skip("test requires cgroup driver") | ||
} |
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.
duplicated with line 429-431
} | ||
|
||
for _, tt := range tests { | ||
tt := tt // capture range variable |
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.
this is no longer needed after go 1.22 (or 1.21? not sure the exact version)
@@ -414,7 +414,7 @@ IPFS flags: | |||
- :nerd_face: `--ipfs-address`: Multiaddr of IPFS API (default uses `$IPFS_PATH` env variable if defined or local directory `~/.ipfs`) | |||
|
|||
Unimplemented `docker run` flags: | |||
`--blkio-weight-device`, `--cpu-rt-*`, `--device-*`, | |||
`--cpu-rt-*`, `--device-cgroup-rule`, |
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.
can you also add these new flags to the this command doc?
BlkioWeight uint16 | ||
// BlkioWeightDevice specifies the Block IO weight (relative device weight) | ||
BlkioWeightDevice []string | ||
// BlkioDeviceReadBps specifies the Block IO read rate limit(bytes per second) of a device | ||
BlkioDeviceReadBps []string | ||
// BlkioDeviceWriteBps specifies the Block IO write rate limit(bytes per second) of a device | ||
BlkioDeviceWriteBps []string | ||
// BlkioDeviceReadIOps specifies the Block IO read rate limit(IO per second) of a device | ||
BlkioDeviceReadIOps []string | ||
// BlkioDeviceWriteIOps specifies the Block IO read rate limit(IO per second) of a device | ||
BlkioDeviceWriteIOps []string |
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.
Do we need to support these flags in other commands? If so I suggest we create a separate struct, e.g., Blkio
.
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 flags are only used in run
and create
. Besides that update
only support blkioweight.
d7d06b4
to
5ebc362
Compare
The failing tests appear to be unrelated to the changes. |
@djdongjin I have addressed most of your comments. PTAL. |
@swagatbora90 is this CI failure related?
https://github.com/containerd/nerdctl/actions/runs/13775727448/job/38524458510?pr=3950 |
Ah I missed that. This is most probably related to my change. Taking a look. |
Actually the mainline test should also fail, but previous I ran the same test on mainline with some debug turned on, and I see this:
So looks like the blkio-weight was never getting applied. Also I know that blkio-weight has been deprecated in cgroupv1 since kernel 5.0 docker/cli#2908. |
b1c4eff
to
7ecd71e
Compare
Also adds HostConfig inspect tests and skip unsupported docker tests Signed-off-by: Swagat Bora <[email protected]>
7ecd71e
to
cfb1704
Compare
func withBlkioReadIOPSDevice(devices []specs.LinuxThrottleDevice) oci.SpecOpts { | ||
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error { | ||
if s.Linux.Resources.BlockIO == nil { | ||
s.Linux.Resources.BlockIO = &specs.LinuxBlockIO{} |
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.
setting zero values has unintended consequences. They can over-write system settings provided by OS. Let's keep nil as nil
|
||
func withBlkioWriteIOPSDevice(devices []specs.LinuxThrottleDevice) oci.SpecOpts { | ||
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error { | ||
if s.Linux.Resources.BlockIO == nil { |
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.
setting zero values has unintended consequences. They can over-write system settings provided by OS. Let's keep nil as nil
|
||
// ensure the file will be removed in case of failed in the test | ||
defer func() { | ||
exec.Command("rm", devPath).Run() |
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: should be assertOk()
}() | ||
|
||
base := testutil.NewBase(t) | ||
defer base.Cmd("rm", "-f", testContainer).Run() |
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: should be assertOk() to prevent leaks
Nerdctl today has support for
--blkio-weight
.This PR adds support for the remaining blkio options (as supported by docker).
Requires cgroup v2 and block device scheduler set to
bfq
Testing