1
0
mirror of https://github.com/kata-containers/kata-containers.git synced 2025-08-20 17:04:02 +00:00

agent: Stop receive message from Receiver if got None

If the container has exited, the sender in notifier watching OOM events
will be dropped after the loop exited, and recv() from the according
receiver will get None.

This will lead two problems for get_oom_event rpc all from agent:

- return an wrong OOM event.
- continuously return OOM events.

Fixes: 

Signed-off-by: bin <bin@hyper.sh>
This commit is contained in:
bin 2021-02-22 21:44:36 +08:00
parent 29d4abf23a
commit bc34cbbce5
2 changed files with 10 additions and 1 deletions
src/agent
rustjail/src/cgroups
src

View File

@ -191,7 +191,10 @@ async fn register_memory_event(
let content = fs::read_to_string(path.clone());
info!(
sl!(),
"OOM event for container: {}, content: {:?}", &containere_id, content
"cgroup event for container: {}, path: {:?}, content: {:?}",
&containere_id,
&path,
content
);
}
}

View File

@ -317,7 +317,13 @@ impl Sandbox {
tokio::spawn(async move {
loop {
let event = rx.recv().await;
// None means the container has exited,
// and sender in OOM notifier is dropped.
if event.is_none() {
return;
}
info!(logger, "got an OOM event {:?}", event);
let _ = tx
.send(container_id.clone())
.await