Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/oci-runtime-tool/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var generateFlags = []cli.Flag{
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)"},
cli.Int64Flag{Name: "linux-pids-limit", Usage: "maximum number of PIDs"},
}

var generateCommand = cli.Command{
Expand Down Expand Up @@ -389,6 +390,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
g.SetLinuxResourcesMemorySwappiness(context.Uint64("linux-mem-swappiness"))
}

if context.IsSet("linux-pids-limit") {
g.SetLinuxResourcesPidsLimit(context.Int64("linux-pids-limit"))
}

var sd string
var sa, ss []string

Expand Down
1 change: 1 addition & 0 deletions completions/bash/oci-runtime-tool
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ _oci-runtime-tool_generate() {
--help
--ipc
--label
--linux-pids-limit
--mount
--mount-cgroups
--mount-label
Expand Down
6 changes: 6 additions & 0 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ func (g *Generator) SetLinuxResourcesMemorySwappiness(swappiness uint64) {
g.spec.Linux.Resources.Memory.Swappiness = &swappiness
}

// SetLinuxResourcesPidsLimit sets g.spec.Linux.Resources.Pids.Limit.
func (g *Generator) SetLinuxResourcesPidsLimit(limit int64) {
g.initSpecLinuxResourcesPids()
g.spec.Linux.Resources.Pids.Limit = &limit
}

// ClearLinuxSysctl clears g.spec.Linux.Sysctl.
func (g *Generator) ClearLinuxSysctl() {
if g.spec == nil || g.spec.Linux == nil {
Expand Down
7 changes: 7 additions & 0 deletions generate/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ func (g *Generator) initSpecLinuxResourcesMemory() {
g.spec.Linux.Resources.Memory = &rspec.Memory{}
}
}

func (g *Generator) initSpecLinuxResourcesPids() {
g.initSpecLinuxResources()
if g.spec.Linux.Resources.Pids == nil {
g.spec.Linux.Resources.Pids = &rspec.Pids{}
}
}
3 changes: 3 additions & 0 deletions man/oci-runtime-tool-generate.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ read the configuration from `config.json`.
**--linux-mem-swappiness**=MEMSWAPPINESS
Sets the swappiness of how the kernel will swap memory pages (Range from 0 to 100).

**--linux-pids-limit**=PIDSLIMIT
Set maximum number of PIDs.

**--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