Skip to content

Commit

Permalink
add support for oom detection
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Phillips <[email protected]>
  • Loading branch information
rphillips committed Apr 28, 2022
1 parent ff5aa21 commit 4203d05
Show file tree
Hide file tree
Showing 5 changed files with 368 additions and 1 deletion.
123 changes: 122 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions conmon-rs/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ strum = { version = "0.24.0", features = ["derive"] }
systemd-journal-logger = "0.5.0"
shadow-rs = "0.11.0"
multimap = "0.8.3"
regex = "1.5.5"
notify = "5.0.0-pre.14"

[build-dependencies]
shadow-rs = "0.11.0"
Expand Down
6 changes: 6 additions & 0 deletions conmon-rs/server/src/child_reaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use crate::{
child::Child,
container_io::{ContainerIO, ContainerIOType, SharedContainerIO},
oom_watcher::OOMWatcher,
};
use anyhow::{anyhow, format_err, Context, Result};
use getset::{CopyGetters, Getters, Setters};
Expand Down Expand Up @@ -204,15 +205,20 @@ impl ReapableChild {

fn watch(&self) -> Result<(Sender<ExitChannelData>, Receiver<ExitChannelData>)> {
let exit_paths = self.exit_paths().clone();
let oom_exit_paths = self.exit_paths().clone();
let pid = self.pid();
// Only one exit code will be written.
let (exit_tx, exit_rx) = broadcast::channel(1);
let exit_tx_clone = exit_tx.clone();
let mut cancel_rx = exit_tx.subscribe();
let timeout = *self.timeout();

task::spawn(async move {
let exit_code: i32;
let mut timed_out = false;
task::spawn(async move {
OOMWatcher::wait_for_oom(&mut cancel_rx, pid, &oom_exit_paths).await
});
let wait_for_exit_code = task::spawn_blocking(move || Self::wait_for_exit_code(pid));
if let Some(timeout) = timeout {
match time::timeout_at(timeout, wait_for_exit_code).await {
Expand Down
1 change: 1 addition & 0 deletions conmon-rs/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod container_log;
mod cri_logger;
mod init;
mod listener;
mod oom_watcher;
mod rpc;
mod server;
mod streams;
Expand Down
Loading

0 comments on commit 4203d05

Please sign in to comment.