YARN-8498. Yarn NodeManager OOM Listener Fails Compilation on Ubuntu 18.04. Contributed by Ayush Saxena.
This commit is contained in:
parent
7fa62e150c
commit
3c96a03dea
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#include "oom_listener.h"
|
#include "oom_listener.h"
|
||||||
|
|
||||||
|
extern inline void cleanup(_oom_listener_descriptors *descriptors);
|
||||||
|
|
||||||
void print_usage(void) {
|
void print_usage(void) {
|
||||||
fprintf(stderr, "oom-listener");
|
fprintf(stderr, "oom-listener");
|
||||||
fprintf(stderr, "Listen to OOM events in a cgroup");
|
fprintf(stderr, "Listen to OOM events in a cgroup");
|
||||||
|
|
|
@ -159,7 +159,7 @@ TEST_F(OOMListenerTest, test_oom) {
|
||||||
const int simulate_cgroups =
|
const int simulate_cgroups =
|
||||||
mock_oom_event_as_user != -1;
|
mock_oom_event_as_user != -1;
|
||||||
|
|
||||||
__pid_t mem_hog_pid = fork();
|
pid_t mem_hog_pid = fork();
|
||||||
if (!mem_hog_pid) {
|
if (!mem_hog_pid) {
|
||||||
// Child process to consume too much memory
|
// Child process to consume too much memory
|
||||||
if (simulate_cgroups) {
|
if (simulate_cgroups) {
|
||||||
|
@ -171,7 +171,7 @@ TEST_F(OOMListenerTest, test_oom) {
|
||||||
// Wait until we are added to the cgroup
|
// Wait until we are added to the cgroup
|
||||||
// so that it is accounted for our mem
|
// so that it is accounted for our mem
|
||||||
// usage
|
// usage
|
||||||
__pid_t cgroupPid;
|
pid_t cgroupPid;
|
||||||
do {
|
do {
|
||||||
std::ifstream tasks;
|
std::ifstream tasks;
|
||||||
tasks.open(tasks_file.c_str(), tasks.in);
|
tasks.open(tasks_file.c_str(), tasks.in);
|
||||||
|
@ -210,7 +210,7 @@ TEST_F(OOMListenerTest, test_oom) {
|
||||||
// There is no race condition with the process
|
// There is no race condition with the process
|
||||||
// running out of memory. If oom is 1 at startup
|
// running out of memory. If oom is 1 at startup
|
||||||
// oom_listener will send an initial notification
|
// oom_listener will send an initial notification
|
||||||
__pid_t listener = fork();
|
pid_t listener = fork();
|
||||||
if (listener == 0) {
|
if (listener == 0) {
|
||||||
// child listener forwarding cgroup events
|
// child listener forwarding cgroup events
|
||||||
_oom_listener_descriptors descriptors = {
|
_oom_listener_descriptors descriptors = {
|
||||||
|
@ -253,8 +253,8 @@ TEST_F(OOMListenerTest, test_oom) {
|
||||||
ASSERT_EQ(0, kill(mem_hog_pid, SIGKILL));
|
ASSERT_EQ(0, kill(mem_hog_pid, SIGKILL));
|
||||||
|
|
||||||
// Verify that process was killed
|
// Verify that process was killed
|
||||||
__WAIT_STATUS mem_hog_status = {};
|
int* mem_hog_status = {};
|
||||||
__pid_t exited0 = wait(mem_hog_status);
|
pid_t exited0 = wait(mem_hog_status);
|
||||||
ASSERT_EQ(mem_hog_pid, exited0)
|
ASSERT_EQ(mem_hog_pid, exited0)
|
||||||
<< "Wrong process exited";
|
<< "Wrong process exited";
|
||||||
ASSERT_EQ(NULL, mem_hog_status)
|
ASSERT_EQ(NULL, mem_hog_status)
|
||||||
|
@ -272,8 +272,8 @@ TEST_F(OOMListenerTest, test_oom) {
|
||||||
<< "Could not delete cgroup " << GetCGroup();
|
<< "Could not delete cgroup " << GetCGroup();
|
||||||
|
|
||||||
// Check that oom_listener exited on the deletion of the cgroup
|
// Check that oom_listener exited on the deletion of the cgroup
|
||||||
__WAIT_STATUS oom_listener_status = {};
|
int* oom_listener_status = {};
|
||||||
__pid_t exited1 = wait(oom_listener_status);
|
pid_t exited1 = wait(oom_listener_status);
|
||||||
ASSERT_EQ(listener, exited1)
|
ASSERT_EQ(listener, exited1)
|
||||||
<< "Wrong process exited";
|
<< "Wrong process exited";
|
||||||
ASSERT_EQ(NULL, oom_listener_status)
|
ASSERT_EQ(NULL, oom_listener_status)
|
||||||
|
|
Loading…
Reference in New Issue