mirror of https://github.com/docker/cli.git
Add `--cpus` support for `docker update`
This fix tries to address the issue raised in 31032 where it was not possible to specify `--cpus` for `docker update`. This fix adds `--cpus` support for `docker update`. In case both `--cpus` and `--cpu-period/--cpu-quota` have been specified, an error will be returned. Related docs has been updated. Integration tests have been added. This fix fixes 31032. This fix is related to 27921, 27958. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
12702bdc81
commit
f21ec0b4d1
|
@ -28,6 +28,7 @@ type updateOptions struct {
|
||||||
memorySwap opts.MemSwapBytes
|
memorySwap opts.MemSwapBytes
|
||||||
kernelMemory opts.MemBytes
|
kernelMemory opts.MemBytes
|
||||||
restartPolicy string
|
restartPolicy string
|
||||||
|
cpus opts.NanoCPUs
|
||||||
|
|
||||||
nFlag int
|
nFlag int
|
||||||
|
|
||||||
|
@ -66,6 +67,9 @@ func NewUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
flags.Var(&opts.kernelMemory, "kernel-memory", "Kernel memory limit")
|
flags.Var(&opts.kernelMemory, "kernel-memory", "Kernel memory limit")
|
||||||
flags.StringVar(&opts.restartPolicy, "restart", "", "Restart policy to apply when a container exits")
|
flags.StringVar(&opts.restartPolicy, "restart", "", "Restart policy to apply when a container exits")
|
||||||
|
|
||||||
|
flags.Var(&opts.cpus, "cpus", "Number of CPUs")
|
||||||
|
flags.SetAnnotation("cpus", "version", []string{"1.29"})
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +101,7 @@ func runUpdate(dockerCli *command.DockerCli, opts *updateOptions) error {
|
||||||
CPUQuota: opts.cpuQuota,
|
CPUQuota: opts.cpuQuota,
|
||||||
CPURealtimePeriod: opts.cpuRealtimePeriod,
|
CPURealtimePeriod: opts.cpuRealtimePeriod,
|
||||||
CPURealtimeRuntime: opts.cpuRealtimeRuntime,
|
CPURealtimeRuntime: opts.cpuRealtimeRuntime,
|
||||||
|
NanoCPUs: opts.cpus.Value(),
|
||||||
}
|
}
|
||||||
|
|
||||||
updateConfig := containertypes.UpdateConfig{
|
updateConfig := containertypes.UpdateConfig{
|
||||||
|
|
Loading…
Reference in New Issue