runtime-rs: check peer close in log_forwarder

The log_forwarder task does not check if the peer has closed, causing a
meaningless loop during the period of “kata vm exit”, when the peer
closed, and “ShutdownContainer RPC received” that aborts the log forwarder.

This patch fixes the problem.

Fixes: #7741

Signed-off-by: Zixuan Tan <tanzixuan.me@gmail.com>
This commit is contained in:
Zixuan Tan 2023-08-25 19:00:07 +08:00
parent a6921dd837
commit dffc16e5b3

View File

@ -64,16 +64,14 @@ impl LogForwarder {
Ok(stream) => { Ok(stream) => {
let stream = BufReader::new(stream); let stream = BufReader::new(stream);
let mut lines = stream.lines(); let mut lines = stream.lines();
while let Ok(line) = lines.next_line().await { while let Ok(Some(l)) = lines.next_line().await {
if let Some(l) = line { match parse_agent_log_level(&l) {
match parse_agent_log_level(&l) { LOG_LEVEL_TRACE => trace!(sl!(), "{}", l),
LOG_LEVEL_TRACE => trace!(sl!(), "{}", l), LOG_LEVEL_DEBUG => debug!(sl!(), "{}", l),
LOG_LEVEL_DEBUG => debug!(sl!(), "{}", l), LOG_LEVEL_WARNING => warn!(sl!(), "{}", l),
LOG_LEVEL_WARNING => warn!(sl!(), "{}", l), LOG_LEVEL_ERROR => error!(sl!(), "{}", l),
LOG_LEVEL_ERROR => error!(sl!(), "{}", l), LOG_LEVEL_CRITICAL => crit!(sl!(), "{}", l),
LOG_LEVEL_CRITICAL => crit!(sl!(), "{}", l), _ => info!(sl!(), "{}", l),
_ => info!(sl!(), "{}", l),
}
} }
} }
} }