Skip to content

Commit

Permalink
Merge pull request #176 from hmeng-19/set_oom_score_adj
Browse files Browse the repository at this point in the history
support setting oom_score_adj
  • Loading branch information
Mrunal Patel authored Aug 5, 2016
2 parents 40d0f78 + 1915407 commit 03e8b89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/ocitools/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.IntFlag{Name: "oom-score-adj", Usage: "oom_score_adj for the container"},
}

var generateCommand = cli.Command{
Expand Down Expand Up @@ -319,6 +320,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
g.AddLinuxGIDMapping(hid, cid, size)
}

if context.IsSet("oom-score-adj") {
g.SetLinuxResourcesOOMScoreAdj(context.Int("oom-score-adj"))
}

var sd string
var sa, ss []string

Expand Down
6 changes: 6 additions & 0 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ func (g *Generator) SetLinuxMountLabel(label string) {
g.spec.Linux.MountLabel = label
}

// SetLinuxResourcesOOMScoreAdj sets g.spec.Linux.Resources.OOMScoreAdj.
func (g *Generator) SetLinuxResourcesOOMScoreAdj(adj int) {
g.initSpecLinuxResources()
g.spec.Linux.Resources.OOMScoreAdj = &adj
}

// SetLinuxResourcesCPUShares sets g.spec.Linux.Resources.CPU.Shares.
func (g *Generator) SetLinuxResourcesCPUShares(shares uint64) {
g.initSpecLinuxResourcesCPU()
Expand Down
3 changes: 3 additions & 0 deletions man/ocitools-generate.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ inside of the container.
using tools like setuid apps. It is a good idea to run unprivileged
containers with this flag.

**--oom-score-adj**=adj
Specifies oom_score_adj for the container.

**--output**=PATH
Instead of writing the configuration JSON to stdout, write it to a
file at *PATH* (overwriting the existing content if a file already
Expand Down

0 comments on commit 03e8b89

Please sign in to comment.