diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-11-05 15:34:24 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-11-05 15:36:20 -0800 |
commit | c47f8afe2334c1395a2acd9ebf5191aa4554907c (patch) | |
tree | 10eccac0af9efe876167cf070396d0c6068c44ec /runsc/specutils | |
parent | caf1e52e18222d9eace348fa53e6857c78e15479 (diff) |
Fix failure setting OOM score adjustment
When OOM score adjustment needs to be set, all the containers need to be
loaded to find all containers that belong to the sandbox. However, each
load signals the container to ensure it is still alive. OOM score
adjustment is set during creation and deletion of every container, generating
a flood of signals to all containers. The fix removes the signal check
when it's not needed.
There is also a race fetching OOM score adjustment value from the parent when
the sandbox exits at the same time (the time it took to signal containers above
made this window quite large). The fix is to store the original value
in the sandbox state file and use it when the value needs to be restored.
Also add more logging and made the existing ones more consistent to help with
debugging.
PiperOrigin-RevId: 340940799
Diffstat (limited to 'runsc/specutils')
-rw-r--r-- | runsc/specutils/specutils.go | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/runsc/specutils/specutils.go b/runsc/specutils/specutils.go index 7b923ddf4..fdbba1832 100644 --- a/runsc/specutils/specutils.go +++ b/runsc/specutils/specutils.go @@ -481,35 +481,6 @@ func GetOOMScoreAdj(pid int) (int, error) { return strconv.Atoi(strings.TrimSpace(string(data))) } -// GetParentPid gets the parent process ID of the specified PID. -func GetParentPid(pid int) (int, error) { - data, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/stat", pid)) - if err != nil { - return 0, err - } - - var cpid string - var name string - var state string - var ppid int - // Parse after the binary name. - _, err = fmt.Sscanf(string(data), - "%v %v %v %d", - // cpid is ignored. - &cpid, - // name is ignored. - &name, - // state is ignored. - &state, - &ppid) - - if err != nil { - return 0, err - } - - return ppid, nil -} - // EnvVar looks for a varible value in the env slice assuming the following // format: "NAME=VALUE". func EnvVar(env []string, name string) (string, bool) { |