File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -182,10 +182,7 @@ func setupOOMScore(shimPid int) error {
182182 return errors .Wrap (err , "get daemon OOM score" )
183183 }
184184 shimScore := score + 1
185- if shimScore > sys .OOMScoreAdjMax {
186- shimScore = sys .OOMScoreAdjMax
187- }
188- if err := sys .SetOOMScore (shimPid , shimScore ); err != nil {
185+ if err := sys .AdjustOOMScore (shimPid , shimScore ); err != nil {
189186 return errors .Wrap (err , "set shim OOM score" )
190187 }
191188 return nil
Original file line number Diff line number Diff line change @@ -61,10 +61,7 @@ func AdjustOOMScore(pid int) error {
6161 return errors .Wrap (err , "get parent OOM score" )
6262 }
6363 shimScore := score + 1
64- if shimScore > sys .OOMScoreAdjMax {
65- shimScore = sys .OOMScoreAdjMax
66- }
67- if err := sys .SetOOMScore (pid , shimScore ); err != nil {
64+ if err := sys .AdjustOOMScore (pid , shimScore ); err != nil {
6865 return errors .Wrap (err , "set shim OOM score" )
6966 }
7067 return nil
Original file line number Diff line number Diff line change @@ -36,6 +36,17 @@ const (
3636 OOMScoreAdjMax = 1000
3737)
3838
39+ // AdjustOOMScore sets the oom score for the provided pid. If the provided score
40+ // is out of range (-1000 - 1000), it is clipped to the min/max value.
41+ func AdjustOOMScore (pid , score int ) error {
42+ if score > OOMScoreAdjMax {
43+ score = OOMScoreAdjMax
44+ } else if score < OOMScoreAdjMin {
45+ score = OOMScoreAdjMin
46+ }
47+ return SetOOMScore (pid , score )
48+ }
49+
3950// SetOOMScore sets the oom score for the provided pid
4051func SetOOMScore (pid , score int ) error {
4152 if score > OOMScoreAdjMax || score < OOMScoreAdjMin {
Original file line number Diff line number Diff line change @@ -25,6 +25,14 @@ const (
2525 OOMScoreAdjMax = 0
2626)
2727
28+ // AdjustOOMScore sets the oom score for the provided pid. If the provided score
29+ // is out of range (-1000 - 1000), it is clipped to the min/max value.
30+ //
31+ // Not implemented on Windows
32+ func AdjustOOMScore (pid , score int ) error {
33+ return nil
34+ }
35+
2836// SetOOMScore sets the oom score for the process
2937//
3038// Not implemented on Windows
You can’t perform that action at this time.
0 commit comments