Skip to content

Commit

Permalink
Merge pull request #116 from samuelkarp/oom-score-adj
Browse files Browse the repository at this point in the history
 generate: do not set OOMScoreAdj if no adjustment
  • Loading branch information
samuelkarp authored Oct 23, 2024
2 parents 44ecabb + 07bfc18 commit edfd91b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 0 additions & 3 deletions pkg/runtime-tools/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,6 @@ func (g *Generator) AdjustCgroupsPath(path string) {
func (g *Generator) AdjustOomScoreAdj(score *nri.OptionalInt) {
if score != nil {
g.SetProcessOOMScoreAdj(int(score.Value))
} else {
g.SetProcessOOMScoreAdj(0)
g.Config.Process.OOMScoreAdj = nil
}
}

Expand Down
20 changes: 20 additions & 0 deletions pkg/runtime-tools/generate/generate_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ var _ = Describe("Adjustment", func() {
})
})

When("existing oom score adj", func() {
It("does not adjust Spec", func() {
var (
spec = makeSpec()
expectedSpec = makeSpec()
adjust = &api.ContainerAdjustment{}
)
oomScoreAdj := 123
spec.Process.OOMScoreAdj = &oomScoreAdj
expectedSpec.Process.OOMScoreAdj = &oomScoreAdj

rg := &rgen.Generator{Config: spec}
xg := xgen.SpecGenerator(rg)

Expect(xg).ToNot(BeNil())
Expect(xg.Adjust(adjust)).To(Succeed())
Expect(spec).To(Equal(expectedSpec))
})
})

When("has CPU shares", func() {
It("adjusts Spec correctly", func() {
var (
Expand Down

0 comments on commit edfd91b

Please sign in to comment.