Skip to content

Commit

Permalink
disable blockio weight in cgroup v2
Browse files Browse the repository at this point in the history
The way libcontainer and lots of other runtime deals with blockio
setting in cgroupv2 is buggy, see [1]

For now, we disable BlockIO until a fix can land in libcontainer.

[1] opencontainers/runc#2786

Signed-off-by: Daniel Dao <[email protected]>
  • Loading branch information
dqminh authored and avagin committed May 12, 2021
1 parent 5a03c2e commit dc0cc80
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
28 changes: 15 additions & 13 deletions runsc/cgroup/cgroup_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,21 @@ func createCgroupConfigFromResources(name string, r *specs.LinuxResources) (*lib
if r.BlockIO.LeafWeight != nil {
c.Resources.BlkioLeafWeight = *r.BlockIO.LeafWeight
}
if r.BlockIO.WeightDevice != nil {
for _, wd := range r.BlockIO.WeightDevice {
var weight, leafWeight uint16
if wd.Weight != nil {
weight = *wd.Weight
}
if wd.LeafWeight != nil {
leafWeight = *wd.LeafWeight
}
weightDevice := libcontainerconfigs.NewWeightDevice(wd.Major, wd.Minor, weight, leafWeight)
c.Resources.BlkioWeightDevice = append(c.Resources.BlkioWeightDevice, weightDevice)
}
}
// FIXME: enable blkio weight. Currently it's setting wrong value
// https://github.com/opencontainers/runc/pull/2786
// if r.BlockIO.WeightDevice != nil {
// for _, wd := range r.BlockIO.WeightDevice {
// var weight, leafWeight uint16
// if wd.Weight != nil {
// weight = *wd.Weight
// }
// if wd.LeafWeight != nil {
// leafWeight = *wd.LeafWeight
// }
// weightDevice := libcontainerconfigs.NewWeightDevice(wd.Major, wd.Minor, weight, leafWeight)
// c.Resources.BlkioWeightDevice = append(c.Resources.BlkioWeightDevice, weightDevice)
// }
// }
if r.BlockIO.ThrottleReadBpsDevice != nil {
for _, td := range r.BlockIO.ThrottleReadBpsDevice {
rate := td.Rate
Expand Down
16 changes: 9 additions & 7 deletions test/root/cgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,15 @@ func TestCgroupV2(t *testing.T) {
want: fmt.Sprintf("%d", 1<<31-1<<30),
skipIfNotFound: true, // swap may be disabled on the machine.
},
{
field: "blkio-weight",
value: 750,
file: "io.bfq.weight",
want: fmt.Sprintf("%d", libcontainercgroups.ConvertBlkIOToCgroupV2Value(750)),
skipIfNotFound: true, // blkio groups may not be available.
},
// FIXME: enable blkio weight. Currently it's setting wrong value, see
// https://github.com/opencontainers/runc/pull/2786
// {
// field: "blkio-weight",
// value: 750,
// file: "io.bfq.weight",
// want: fmt.Sprintf("%d", libcontainercgroups.ConvertBlkIOToCgroupV2Value(750)),
// skipIfNotFound: true, // blkio groups may not be available.
// },
{
field: "pids-limit",
value: 1000,
Expand Down

0 comments on commit dc0cc80

Please sign in to comment.