agent: remove check! in child process because we cant' see logs.

The check macro will log the errors but the log in child process can't
be seen, just ignore it.

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang 2020-10-13 15:26:35 +08:00
parent a18899f1a3
commit 09aca49ed7

View File

@ -335,10 +335,7 @@ pub fn init_child() {
Ok(_) => (), Ok(_) => (),
Err(e) => { Err(e) => {
log_child!(cfd_log, "child exit: {:?}", e); log_child!(cfd_log, "child exit: {:?}", e);
check!( let _ = write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str()),
"write_sync in init_child()"
);
return; return;
} }
} }
@ -490,19 +487,13 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {
sched::setns(fd, s).or_else(|e| { sched::setns(fd, s).or_else(|e| {
if s == CloneFlags::CLONE_NEWUSER { if s == CloneFlags::CLONE_NEWUSER {
if e.as_errno().unwrap() != Errno::EINVAL { if e.as_errno().unwrap() != Errno::EINVAL {
check!( let _ = write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str()),
"write_sync for CLONE_NEWUSER"
);
return Err(e); return Err(e);
} }
Ok(()) Ok(())
} else { } else {
check!( let _ = write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str());
write_sync(cwfd, SYNC_FAILED, format!("{:?}", e).as_str()),
"write_sync for sched::setns"
);
Err(e) Err(e)
} }
})?; })?;
@ -578,14 +569,12 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {
if guser.additional_gids.len() > 0 { if guser.additional_gids.len() > 0 {
setgroups(guser.additional_gids.as_slice()).map_err(|e| { setgroups(guser.additional_gids.as_slice()).map_err(|e| {
check!( let _ = write_sync(
write_sync(
cwfd, cwfd,
SYNC_FAILED, SYNC_FAILED,
format!("setgroups failed: {:?}", e).as_str() format!("setgroups failed: {:?}", e).as_str(),
),
"write_sync for setgroups"
); );
e e
})?; })?;
} }
@ -650,9 +639,9 @@ fn do_init_child(cwfd: RawFd) -> Result<()> {
// notify parent that the child's ready to start // notify parent that the child's ready to start
write_sync(cwfd, SYNC_SUCCESS, "")?; write_sync(cwfd, SYNC_SUCCESS, "")?;
log_child!(cfd_log, "ready to run exec"); log_child!(cfd_log, "ready to run exec");
check!(unistd::close(cfd_log), "closing cfd log"); let _ = unistd::close(cfd_log);
check!(unistd::close(crfd), "closing crfd"); let _ = unistd::close(crfd);
check!(unistd::close(cwfd), "closing cwfd"); let _ = unistd::close(cwfd);
if oci_process.terminal { if oci_process.terminal {
unistd::setsid()?; unistd::setsid()?;