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 @@ -58,6 +58,7 @@ var generateFlags = []cli.Flag{
cli.StringSliceFlag{Name: "seccomp-errno", Usage: "specifies syscalls to be added to list that returns an error"},
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.BoolFlag{Name: "disable-oom-kill", Usage: "disable OOM Killer"},
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)"},
Expand Down Expand Up @@ -333,6 +334,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
g.AddLinuxGIDMapping(hid, cid, size)
}

if context.IsSet("disable-oom-kill") {
g.SetLinuxResourcesDisableOOMKiller(context.Bool("disable-oom-kill"))
}

if context.IsSet("oom-score-adj") {
g.SetLinuxResourcesOOMScoreAdj(context.Int("oom-score-adj"))
}
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 @@ -277,6 +277,7 @@ _oci-runtime-tool_generate() {
--cgroup
--cgroup-path
--cwd
--disable-oom-kill
--env
--gid
--gidmappings
Expand Down
6 changes: 6 additions & 0 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ func (g *Generator) SetLinuxMountLabel(label string) {
g.spec.Linux.MountLabel = label
}

// SetLinuxResourcesDisableOOMKiller sets g.spec.Linux.Resources.DisableOOMKiller.
func (g *Generator) SetLinuxResourcesDisableOOMKiller(disable bool) {
g.initSpecLinuxResources()
g.spec.Linux.Resources.DisableOOMKiller = &disable
}

// SetLinuxResourcesOOMScoreAdj sets g.spec.Linux.Resources.OOMScoreAdj.
func (g *Generator) SetLinuxResourcesOOMScoreAdj(adj int) {
g.initSpecLinuxResources()
Expand Down
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 @@ -57,6 +57,9 @@ read the configuration from `config.json`.
**--cwd**=PATH
Current working directory for the process

**--disable-oom-kill**=true|false
Whether to disable OOM Killer for the container or not.

**--env**=[]
Set environment variables e.g. key=value.
This option allows you to specify arbitrary environment variables
Expand Down