mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
add log messages when write to oom_score_adj fails
Signed-off-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
This commit is contained in:
parent
32f24bc3c5
commit
9ed54d3c67
2 changed files with 19 additions and 5 deletions
|
@ -37,6 +37,7 @@ import (
|
||||||
lntypes "github.com/docker/libnetwork/types"
|
lntypes "github.com/docker/libnetwork/types"
|
||||||
"github.com/golang/protobuf/ptypes"
|
"github.com/golang/protobuf/ptypes"
|
||||||
"github.com/opencontainers/runc/libcontainer/label"
|
"github.com/opencontainers/runc/libcontainer/label"
|
||||||
|
rsystem "github.com/opencontainers/runc/libcontainer/system"
|
||||||
"github.com/opencontainers/runc/libcontainer/user"
|
"github.com/opencontainers/runc/libcontainer/user"
|
||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
)
|
)
|
||||||
|
@ -1147,10 +1148,16 @@ func setupOOMScoreAdj(score int) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = f.WriteString(strconv.Itoa(score))
|
|
||||||
|
stringScore := strconv.Itoa(score)
|
||||||
|
_, err = f.WriteString(stringScore)
|
||||||
if os.IsPermission(err) {
|
if os.IsPermission(err) {
|
||||||
// Setting oom_score_adj does not work in an
|
// Setting oom_score_adj does not work in an
|
||||||
// unprivileged container. Ignore the error.
|
// unprivileged container. Ignore the error, but log
|
||||||
|
// it if we appear not to be in that situation.
|
||||||
|
if !rsystem.RunningInUserNS() {
|
||||||
|
logrus.Debugf("Permission denied writing %q to /proc/self/oom_score_adj", stringScore)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/docker/docker/utils"
|
"github.com/docker/docker/utils"
|
||||||
"github.com/golang/protobuf/ptypes"
|
"github.com/golang/protobuf/ptypes"
|
||||||
"github.com/golang/protobuf/ptypes/timestamp"
|
"github.com/golang/protobuf/ptypes/timestamp"
|
||||||
|
rsystem "github.com/opencontainers/runc/libcontainer/system"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/grpclog"
|
"google.golang.org/grpc/grpclog"
|
||||||
|
@ -429,15 +430,21 @@ func (r *remote) runContainerdDaemon() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setOOMScore(pid, score int) error {
|
func setOOMScore(pid, score int) error {
|
||||||
f, err := os.OpenFile(fmt.Sprintf("/proc/%d/oom_score_adj", pid), os.O_WRONLY, 0)
|
oomScoreAdjPath := fmt.Sprintf("/proc/%d/oom_score_adj", pid)
|
||||||
|
f, err := os.OpenFile(oomScoreAdjPath, os.O_WRONLY, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = f.WriteString(strconv.Itoa(score))
|
stringScore := strconv.Itoa(score)
|
||||||
|
_, err = f.WriteString(stringScore)
|
||||||
f.Close()
|
f.Close()
|
||||||
if os.IsPermission(err) {
|
if os.IsPermission(err) {
|
||||||
// Setting oom_score_adj does not work in an
|
// Setting oom_score_adj does not work in an
|
||||||
// unprivileged container. Ignore the error.
|
// unprivileged container. Ignore the error, but log
|
||||||
|
// it if we appear not to be in that situation.
|
||||||
|
if !rsystem.RunningInUserNS() {
|
||||||
|
logrus.Debugf("Permission denied writing %q to %s", stringScore, oomScoreAdjPath)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue