mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-02 09:24:35 +00:00
Merge pull request #8773 from justxuewei/dbs-k8s-fragile
This commit is contained in:
@@ -3,19 +3,20 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
|
||||||
use eventfd::{eventfd, EfdFlags};
|
|
||||||
use nix::sys::eventfd;
|
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::pipestream::PipeStream;
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
use eventfd::{eventfd, EfdFlags};
|
||||||
use futures::StreamExt as _;
|
use futures::StreamExt as _;
|
||||||
use inotify::{Inotify, WatchMask};
|
use inotify::{Inotify, WatchMask};
|
||||||
|
use nix::sys::eventfd;
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio::sync::mpsc::{channel, Receiver};
|
use tokio::sync::mpsc::{channel, Receiver};
|
||||||
|
|
||||||
|
use crate::pipestream::PipeStream;
|
||||||
|
|
||||||
// Convenience function to obtain the scope logger.
|
// Convenience function to obtain the scope logger.
|
||||||
fn sl() -> slog::Logger {
|
fn sl() -> slog::Logger {
|
||||||
slog_scope::logger().new(o!("subsystem" => "cgroups_notifier"))
|
slog_scope::logger().new(o!("subsystem" => "cgroups_notifier"))
|
||||||
@@ -165,7 +166,6 @@ async fn register_memory_event(
|
|||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
let sender = sender.clone();
|
|
||||||
let mut buf = [0u8; 8];
|
let mut buf = [0u8; 8];
|
||||||
match eventfd_stream.read(&mut buf).await {
|
match eventfd_stream.read(&mut buf).await {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -173,14 +173,15 @@ async fn register_memory_event(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let content = fs::read_to_string(path.clone());
|
if let Ok(times) = get_value_from_cgroup(&path, "oom_kill") {
|
||||||
info!(
|
if times < 1 {
|
||||||
sl(),
|
// Do not send an OOM event in the case where no OOM has occurred
|
||||||
"cgroup event for container: {}, path: {:?}, content: {:?}",
|
continue;
|
||||||
&containere_id,
|
}
|
||||||
&path,
|
}
|
||||||
content
|
// Send an OOM event in two cases:
|
||||||
);
|
// 1. The value is not empty && times > 0: OOM kill has occurred.
|
||||||
|
// 2. The value is empty: Do what previous implemention did.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user