From 9924fbbc7043816dfe76b94fea2bcf8f7cc1096d Mon Sep 17 00:00:00 2001 From: Fupan Li Date: Tue, 29 Apr 2025 12:15:51 +0800 Subject: [PATCH] shimv2: fix the issue logger write failed It's better to open the log pipe file with read & write option, otherwise, once the containerd reboot and closed the read endpoint, kata shim would write the log pipe with broken pipe error. Fixes: #11207 Signed-off-by: Fupan Li --- src/runtime-rs/crates/shim/src/logger.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/shim/src/logger.rs b/src/runtime-rs/crates/shim/src/logger.rs index 8a9558ff6..c5d7f225c 100644 --- a/src/runtime-rs/crates/shim/src/logger.rs +++ b/src/runtime-rs/crates/shim/src/logger.rs @@ -11,10 +11,14 @@ use anyhow::{Context, Result}; use crate::Error; pub(crate) fn set_logger(path: &str, sid: &str, is_debug: bool) -> Result { + //it's better to open the log pipe file with read & write option, + //otherwise, once the containerd reboot and closed the read endpoint, + //kata shim would write the log pipe with broken pipe error. let fifo = std::fs::OpenOptions::new() .custom_flags(libc::O_NONBLOCK) .create(true) - .append(true) + .read(true) + .write(true) .open(path) .context(Error::FileOpen(path.to_string()))?;