-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add oom monitor for rustshim #229
Conversation
751a811
to
cc3b2bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your pr, some of the methods already exist, so please change your code, thanks.
9d1ccc9
to
7833296
Compare
@mxpv @Burning1020 Hello, are there any further plans for this submission? |
7833296
to
b63fd81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few suggestions.
Also I'd love to see some unit tests if possible.
Here I suggest the UT could be:
match fork().unwrap() {
ForkResult::Parent { child } => {
let pid = child.as_raw() as u64;
cg.add_task_by_tgid(CgroupPid::from(pid)).unwrap(); // add child to cgroup
waitpid(Some(child), None).unwrap();
}
ForkResult::Child => {
std::thread::sleep(Duration::from_millis(100));
let mut v: Vec<u8> = vec![];
v.resize(11 * 1024 * 1024, 0);
exit(0);
}
};
|
Thanks for your comments. |
@Burning1020 @mxpv Hello, there are two points that i]m not quite sure about this PR:
|
|
796f337
to
e6cc1b4
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #229 +/- ##
=======================================
Coverage ? 36.82%
=======================================
Files ? 56
Lines ? 5241
Branches ? 0
=======================================
Hits ? 1930
Misses ? 3311
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@Burning1020 @mxpv @kzys hello, commit contains ut is pushed. |
e6cc1b4
to
7d96df2
Compare
@mxpv @Burning1020 Revised according to the feedback, please review, thanks. |
CI needs some work. |
7d96df2
to
485eba1
Compare
485eba1
to
c80133d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks
ffb2407
to
dbd3a4e
Compare
dbd3a4e
to
c6f29ff
Compare
@Burning1020 @mxpv
let path_from_cgorup = cgroup_memory::get_path_from_cgorup(resp.pid).await?; Modify the logic of registring the oom monitor to, during the construction of oom monitor, when error happens, not return, but instead log the error msgs. #[cfg(target_os = "linux")]
async fn monitor_oom(id: &String, pid: u32, tx: EventSender) -> Result<()> {
if !is_cgroup2_unified_mode() {
let path_from_cgorup = cgroup_memory::get_path_from_cgorup(pid).await?;
let (mount_root, mount_point) =
cgroup_memory::get_existing_cgroup_mem_path(path_from_cgorup).await?;
let mem_cgroup_path = mount_point + &mount_root;
let rx = cgroup_memory::register_memory_event(
id,
Path::new(&mem_cgroup_path),
"memory.oom_control",
)
.await
.map_err(other_error!(e, "register_memory_event failed:"))?;
run_oom_monitor(rx, id.to_string(), tx);
}
Ok(())
}
async fn start(&self, _ctx: &TtrpcContext, req: StartRequest) -> TtrpcResult<StartResponse> {
......
#[cfg(target_os = "linux")]
if let Err(e) = monitor_oom(&req.id, resp.pid, self.tx.clone()).await {
error!("monitor_oom failed: {:?}.", e);
}
......
} |
@mxpv @Burning1020 Thx for the review, is cgroup2 version of oom monitor needed? |
@aa624545345 what would be nice to have! |
Cherry-pick from containerd#229
Registering and reporting cgroup OOM events for Rust shim。 #227