Skip to content

Commit 11ba624

Browse files
committed
feat: add blkio device options to docker container update
Closes #3325 Related to moby/moby#52651 Signed-off-by: Alexis Couvreur <alexiscouvreur.pro@gmail.com>
1 parent 4ed0e4e commit 11ba624

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

cli/command/container/update.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ import (
1717

1818
type updateOptions struct {
1919
blkioWeight uint16
20+
blkioWeightDevice opts.WeightdeviceOpt
2021
cpuPeriod int64
2122
cpuQuota int64
2223
cpuRealtimePeriod int64
2324
cpuRealtimeRuntime int64
2425
cpusetCpus string
2526
cpusetMems string
2627
cpuShares int64
28+
deviceReadBps opts.ThrottledeviceOpt
29+
deviceWriteBps opts.ThrottledeviceOpt
30+
deviceReadIOps opts.ThrottledeviceOpt
31+
deviceWriteIOps opts.ThrottledeviceOpt
2732
memory opts.MemBytes
2833
memoryReservation opts.MemBytes
2934
memorySwap opts.MemSwapBytes
@@ -58,6 +63,7 @@ func newUpdateCommand(dockerCLI command.Cli) *cobra.Command {
5863

5964
flags := cmd.Flags()
6065
flags.Uint16Var(&options.blkioWeight, "blkio-weight", 0, `Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)`)
66+
flags.Var(&options.blkioWeightDevice, "blkio-weight-device", "Block IO weight (relative device weight)")
6167
flags.Int64Var(&options.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period")
6268
flags.Int64Var(&options.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota")
6369
flags.Int64Var(&options.cpuRealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds")
@@ -67,6 +73,10 @@ func newUpdateCommand(dockerCLI command.Cli) *cobra.Command {
6773
flags.StringVar(&options.cpusetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
6874
flags.StringVar(&options.cpusetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)")
6975
flags.Int64VarP(&options.cpuShares, "cpu-shares", "c", 0, "CPU shares (relative weight)")
76+
flags.Var(&options.deviceReadBps, "device-read-bps", "Limit read rate (bytes per second) from a device")
77+
flags.Var(&options.deviceReadIOps, "device-read-iops", "Limit read rate (IO per second) from a device")
78+
flags.Var(&options.deviceWriteBps, "device-write-bps", "Limit write rate (bytes per second) to a device")
79+
flags.Var(&options.deviceWriteIOps, "device-write-iops", "Limit write rate (IO per second) to a device")
7080
flags.VarP(&options.memory, "memory", "m", "Memory limit")
7181
flags.Var(&options.memoryReservation, "memory-reservation", "Memory soft limit")
7282
flags.Var(&options.memorySwap, "memory-swap", `Swap limit equal to memory plus swap: -1 to enable unlimited swap`)
@@ -111,9 +121,14 @@ func runUpdate(ctx context.Context, dockerCli command.Cli, options *updateOption
111121
updateConfig := client.ContainerUpdateOptions{
112122
Resources: &containertypes.Resources{
113123
BlkioWeight: options.blkioWeight,
124+
BlkioWeightDevice: options.blkioWeightDevice.Value(),
114125
CpusetCpus: options.cpusetCpus,
115126
CpusetMems: options.cpusetMems,
116127
CPUShares: options.cpuShares,
128+
DeviceReadBps: options.deviceReadBps.Value(),
129+
DeviceReadIOps: options.deviceReadIOps.Value(),
130+
DeviceWriteBps: options.deviceWriteBps.Value(),
131+
DeviceWriteIOps: options.deviceWriteIOps.Value(),
117132
Memory: options.memory.Value(),
118133
MemoryReservation: options.memoryReservation.Value(),
119134
MemorySwap: options.memorySwap.Value(),

0 commit comments

Comments
 (0)