Docker uses "-c" to mean "--cpu-shares" in create and run

Add support for -c as an alias for --cpu-shares to be compatible with
Docker.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2022-07-12 14:53:17 -04:00
committed by Matthew Heon
parent ffd2e6df9d
commit b29a52a48a
5 changed files with 6 additions and 6 deletions

View File

@ -849,9 +849,9 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
_ = cmd.RegisterFlagCompletionFunc(cpuRtRuntimeFlagName, completion.AutocompleteNone)
cpuSharesFlagName := "cpu-shares"
createFlags.Uint64Var(
createFlags.Uint64VarP(
&cf.CPUShares,
cpuSharesFlagName, 0,
cpuSharesFlagName, "c", 0,
"CPU shares (relative weight)",
)
_ = cmd.RegisterFlagCompletionFunc(cpuSharesFlagName, completion.AutocompleteNone)

View File

@ -61,7 +61,7 @@ The sum of all runtimes across containers cannot exceed the amount allotted to t
This option is not supported on cgroups V2 systems.
#### **--cpu-shares**=*shares*
#### **--cpu-shares**, **-c**=*shares*
CPU shares (relative weight)

View File

@ -201,7 +201,7 @@ The sum of all runtimes across containers cannot exceed the amount allotted to t
This flag is not supported on cgroups V2 systems.
#### **--cpu-shares**=*shares*
#### **--cpu-shares**, **-c**=*shares*
CPU shares (relative weight)

View File

@ -220,7 +220,7 @@ The sum of all runtimes across containers cannot exceed the amount allotted to t
This flag is not supported on cgroups V2 systems.
#### **--cpu-shares**=*shares*
#### **--cpu-shares**, **-c**=*shares*
CPU shares (relative weight).

View File

@ -94,7 +94,7 @@ var _ = Describe("Podman run cpu", func() {
Expect(result).Should(Exit(0))
Expect(result.OutputToString()).To(Equal("10000"))
} else {
result := podmanTest.Podman([]string{"run", "--rm", "--cpu-shares=2", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.shares"})
result := podmanTest.Podman([]string{"run", "--rm", "-c", "2", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.shares"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(result.OutputToString()).To(Equal("2"))