Skip to content

Commit

Permalink
Merge pull request #175 from hmeng-19/add_generate_options
Browse files Browse the repository at this point in the history
add new generate options for setting cpu/mem
  • Loading branch information
Mrunal Patel authored Sep 6, 2016
2 parents 1a3f3c6 + 092cb7c commit 089d971
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
65 changes: 65 additions & 0 deletions cmd/ocitools/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ var generateFlags = []cli.Flag{
cli.StringFlag{Name: "template", Usage: "base template to use for creating the configuration"},
cli.StringSliceFlag{Name: "label", Usage: "add annotations to the configuration e.g. key=value"},
cli.IntFlag{Name: "oom-score-adj", Usage: "oom_score_adj for the container"},
cli.Uint64Flag{Name: "linux-cpu-shares", Usage: "the relative share of CPU time available to the tasks in a cgroup"},
cli.Uint64Flag{Name: "linux-cpu-period", Usage: "the CPU period to be used for hardcapping (in usecs)"},
cli.Uint64Flag{Name: "linux-cpu-quota", Usage: "the allowed CPU time in a given period (in usecs)"},
cli.Uint64Flag{Name: "linux-realtime-runtime", Usage: "the time realtime scheduling may use (in usecs)"},
cli.Uint64Flag{Name: "linux-realtime-period", Usage: "CPU period to be used for realtime scheduling (in usecs)"},
cli.StringFlag{Name: "linux-cpus", Usage: "CPUs to use within the cpuset (default is to use any CPU available)"},
cli.StringFlag{Name: "linux-mems", Usage: "list of memory nodes in the cpuset (default is to use any available memory node)"},
cli.Uint64Flag{Name: "linux-mem-limit", Usage: "memory limit (in bytes)"},
cli.Uint64Flag{Name: "linux-mem-reservation", Usage: "memory reservation or soft limit (in bytes)"},
cli.Uint64Flag{Name: "linux-mem-swap", Usage: "total memory limit (memory + swap) (in bytes)"},
cli.Uint64Flag{Name: "linux-mem-kernel-limit", Usage: "kernel memory limit (in bytes)"},
cli.Uint64Flag{Name: "linux-mem-kernel-tcp", Usage: "kernel memory limit for tcp (in bytes)"},
cli.Uint64Flag{Name: "linux-mem-swappiness", Usage: "how aggressive the kernel will swap memory pages (Range from 0 to 100)"},
}

var generateCommand = cli.Command{
Expand Down Expand Up @@ -324,6 +337,58 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
g.SetLinuxResourcesOOMScoreAdj(context.Int("oom-score-adj"))
}

if context.IsSet("linux-cpu-shares") {
g.SetLinuxResourcesCPUShares(context.Uint64("linux-cpu-shares"))
}

if context.IsSet("linux-cpu-period") {
g.SetLinuxResourcesCPUPeriod(context.Uint64("linux-cpu-period"))
}

if context.IsSet("linux-cpu-quota") {
g.SetLinuxResourcesCPUQuota(context.Uint64("linux-cpu-quota"))
}

if context.IsSet("linux-realtime-runtime") {
g.SetLinuxResourcesCPURealtimeRuntime(context.Uint64("linux-realtime-runtime"))
}

if context.IsSet("linux-realtime-period") {
g.SetLinuxResourcesCPURealtimePeriod(context.Uint64("linux-realtime-period"))
}

if context.IsSet("linux-cpus") {
g.SetLinuxResourcesCPUCpus(context.String("linux-cpus"))
}

if context.IsSet("linux-mems") {
g.SetLinuxResourcesCPUMems(context.String("linux-mems"))
}

if context.IsSet("linux-mem-limit") {
g.SetLinuxResourcesMemoryLimit(context.Uint64("linux-mem-limit"))
}

if context.IsSet("linux-mem-reservation") {
g.SetLinuxResourcesMemoryReservation(context.Uint64("linux-mem-reservation"))
}

if context.IsSet("linux-mem-swap") {
g.SetLinuxResourcesMemorySwap(context.Uint64("linux-mem-swap"))
}

if context.IsSet("linux-mem-kernel-limit") {
g.SetLinuxResourcesMemoryKernel(context.Uint64("linux-mem-kernel-limit"))
}

if context.IsSet("linux-mem-kernel-tcp") {
g.SetLinuxResourcesMemoryKernelTCP(context.Uint64("linux-mem-kernel-tcp"))
}

if context.IsSet("linux-mem-swappiness") {
g.SetLinuxResourcesMemorySwappiness(context.Uint64("linux-mem-swappiness"))
}

var sd string
var sa, ss []string

Expand Down
39 changes: 39 additions & 0 deletions man/ocitools-generate.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,45 @@ read the configuration from `config.json`.
**--label**=[]
Add annotations to the configuration e.g. key=value.

**--linux-cpu-shares**=CPUSHARES
Specifies a relative share of CPU time available to the tasks in a cgroup.

**--linux-cpu-period**=CPUPERIOD
Specifies a period of time in microseconds for how regularly a cgroup's access to CPU resources should be reallocated (CFS scheduler only).

**--linux-cpu-quota**=CPUQUOTA
Specifies the total amount of time in microseconds for which all tasks in a cgroup can run during one period.

**--linux-realtime-runtime**=REALTIMERUNTIME
Specifies a period of time in microseconds for the longest continuous period in which the tasks in a cgroup have access to CPU resources.

**--linux-realtime-period**=REALTIMEPERIOD
Sets the CPU period to be used for realtime scheduling (in usecs). Same as **--linux-cpu-period** but applies to realtime scheduler only.

**--linux-cpus**=CPUS
Sets the CPUs to use within the cpuset (default is to use any CPU available).

**--linux-mems**=MEMS
Sets the list of memory nodes in the cpuset (default is to use any available memory node).

**--linux-mem-limit**=MEMLIMIT
Sets the limit of memory usage in bytes.

**--linux-mem-reservation**=MEMRESERVATION
Sets the soft limit of memory usage in bytes.

**--linux-mem-swap**=MEMSWAP
Sets the total memory limit (memory + swap) in bytes.

**--linux-mem-kernel-limit**=MEMKERNELLIMIT
Sets the hard limit of kernel memory in bytes.

**--linux-mem-kernel-tcp**=MEMKERNELTCP
Sets the hard limit of kernel TCP buffer memory in bytes.

**--linux-mem-swappiness**=MEMSWAPPINESS
Sets the swappiness of how the kernel will swap memory pages (Range from 0 to 100).

**--mount**=*PATH*
Use a mount namespace where *PATH* is an existing mount namespace file
to join. The special *PATH* empty-string creates a new namespace.
Expand Down

0 comments on commit 089d971

Please sign in to comment.