conmon: Create oom file for container on OOM notification
@@ -687,11 +687,20 @@ int main(int argc, char *argv[])
pipe = STDOUT_PIPE;
else if (masterfd == masterfd_stderr)
pipe = STDERR_PIPE;
+ else if (masterfd == efd) {
+ if (read(efd, &oom_event, sizeof(uint64_t)) != sizeof(uint64_t))
+ nwarn("Failed to read event from eventfd");
+ ninfo("OOM received");
+ if (open("oom", O_CREAT, 0666) < 0) {
+ nwarn("Failed to write oom file");
+ }
+ }
else {
nwarn("unknown pipe fd");
goto out;
}
+ if (masterfd == masterfd_stdout || masterfd == masterfd_stderr) {
num_read = read(masterfd, buf, BUF_SIZE);
if (num_read <= 0)
goto out;
@@ -700,6 +709,7 @@ int main(int argc, char *argv[])
nwarn("write_k8s_log failed");
goto out;
}
+ }
} else if (evlist[i].events & (EPOLLHUP | EPOLLERR)) {
printf("closing fd %d\n", evlist[i].data.fd);
if (close(evlist[i].data.fd) < 0)
