|
@@ -3,8 +3,10 @@ package specconv // import "github.com/docker/docker/rootless/specconv"
|
|
import (
|
|
import (
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"strconv"
|
|
"strconv"
|
|
|
|
+ "strings"
|
|
|
|
|
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
|
|
|
+ "github.com/sirupsen/logrus"
|
|
)
|
|
)
|
|
|
|
|
|
// ToRootless converts spec to be compatible with "rootless" runc.
|
|
// ToRootless converts spec to be compatible with "rootless" runc.
|
|
@@ -19,10 +21,13 @@ func ToRootless(spec *specs.Spec, v2Controllers []string) error {
|
|
func getCurrentOOMScoreAdj() int {
|
|
func getCurrentOOMScoreAdj() int {
|
|
b, err := ioutil.ReadFile("/proc/self/oom_score_adj")
|
|
b, err := ioutil.ReadFile("/proc/self/oom_score_adj")
|
|
if err != nil {
|
|
if err != nil {
|
|
|
|
+ logrus.WithError(err).Warn("failed to read /proc/self/oom_score_adj")
|
|
return 0
|
|
return 0
|
|
}
|
|
}
|
|
- i, err := strconv.Atoi(string(b))
|
|
|
|
|
|
+ s := string(b)
|
|
|
|
+ i, err := strconv.Atoi(strings.TrimSpace(s))
|
|
if err != nil {
|
|
if err != nil {
|
|
|
|
+ logrus.WithError(err).Warnf("failed to parse /proc/self/oom_score_adj (%q)", s)
|
|
return 0
|
|
return 0
|
|
}
|
|
}
|
|
return i
|
|
return i
|