summaryrefslogtreecommitdiffhomepage
path: root/runsc
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-08-07 12:53:44 -0700
committergVisor bot <gvisor-bot@google.com>2019-08-07 12:55:06 -0700
commit79cc4397fd99fbdd5c74ac5bb7804a463d7981d8 (patch)
tree1cb70fe6aeef5585460262516b94009d974e1a72 /runsc
parent67a3f4039da1a50dcc4b3e488c663b0d730d4332 (diff)
Set gofer's OOM score adjustment
Updates #512 PiperOrigin-RevId: 262195448
Diffstat (limited to 'runsc')
-rw-r--r--runsc/container/container.go24
1 files changed, 5 insertions, 19 deletions
diff --git a/runsc/container/container.go b/runsc/container/container.go
index 2a8453931..bbb364214 100644
--- a/runsc/container/container.go
+++ b/runsc/container/container.go
@@ -1176,30 +1176,16 @@ func (c *Container) adjustOOMScoreAdj(conf *boot.Config) error {
return nil
}
- // Set oom_score_adj for the sandbox.
+ // Set the lowest of all containers oom_score_adj to the sandbox.
if err := setOOMScoreAdj(c.Sandbox.Pid, lowScore); err != nil {
return fmt.Errorf("setting oom_score_adj for sandbox %q: %v", c.Sandbox.ID, err)
}
- // Set the gofer's oom_score_adj to the minimum of -500 and the
- // sandbox's oom_score_adj to better ensure that the sandbox is killed
- // before the gofer.
- //
- // TODO(gvisor.dev/issue/601) Set oom_score_adj for the gofer to
- // the same oom_score_adj as the sandbox.
- goferScoreAdj := -500
- if lowScore < goferScoreAdj {
- goferScoreAdj = lowScore
+ // Set container's oom_score_adj to the gofer since it is dedicated to the
+ // container, in case the gofer uses up too much memory.
+ if err := setOOMScoreAdj(c.GoferPid, *c.Spec.Process.OOMScoreAdj); err != nil {
+ return fmt.Errorf("setting gofer oom_score_adj for container %q: %v", c.ID, err)
}
-
- // Set oom_score_adj for gofers for all containers in the sandbox.
- for _, container := range containers {
- err := setOOMScoreAdj(container.GoferPid, goferScoreAdj)
- if err != nil {
- return fmt.Errorf("setting oom_score_adj for container %q: %v", container.ID, err)
- }
- }
-
return nil
}