(this was introduced in 44240116aa)
Setting the oom-score-adj to -1000 is only possible if the parent process
either has no score set, or if the score is set to -1000.
However, the current implementation of GetOOMScoreAdj conflates situations
where either _no_ oom-score is set, _or_ oom-score is set, but set to 0.
In the latter case, the test would fail:
--- FAIL: TestSetOOMScoreBoundaries (0.01s)
oom_linux_test.go:79: assertion failed: 0 (adjustment int) != -1000 (OOMScoreAdjMin int)
FAIL
To prevent failures in this situation, skip that part of the test in the
above situation.
Also update the description of GetOOMScoreAdj to clarify its behavior.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
SetOOMScore requires both privileged (root) and non-user namespace,
for negative values, so adjust the pre-conditions accordingly.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
These are currently only used inside this package, so we might
as well un-export them until we need them elsewhere.
Also updated SetOOMScore() to first check for privileged; check for privileged
looks to be the "faster" path, and checking it first could (in case of non-
privileged) save having to read and parse /proc/self/uid_map.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>