From 6346e04cf7d7e9c26844d624cc3e5fb3c3b25178 Mon Sep 17 00:00:00 2001 From: Pavel Mores Date: Thu, 1 Feb 2024 12:01:35 +0100 Subject: [PATCH] runtime-rs: fix handling of TTRCP_ADDRESS Since cri-o doesn't seem to use address for event publishing as mentioned in the previous commit it will not send it. However, the exact way of not sending it is unfortunately different from what is assumed by runtime-rs. Due to an implementation detail of cri-o which uses containerd libraries for some low-level tasks, TTRPC_ADDRESS will not be missing from environment as assumed, instead it will be present with an empty value. This commit contains a small adjustment to account for that and use LogForwarder even if TTRPC_ADDRESS is present, but with an empty value. Fixes #8985 Signed-off-by: Pavel Mores --- src/runtime-rs/crates/service/src/event.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime-rs/crates/service/src/event.rs b/src/runtime-rs/crates/service/src/event.rs index 79cf711027..fc5868f3a8 100644 --- a/src/runtime-rs/crates/service/src/event.rs +++ b/src/runtime-rs/crates/service/src/event.rs @@ -38,12 +38,14 @@ pub(crate) trait Forwarder { /// `TTRPC_ADDRESS` existing. Otherwise, fall back to `LogForwarder`. pub(crate) async fn new_event_publisher(namespace: &str) -> Result> { let fwd: Box = match env::var(TTRPC_ADDRESS_ENV) { - Ok(address) => Box::new( + Ok(address) if !address.is_empty() => Box::new( ContainerdForwarder::new(namespace, &address) .await .context("new containerd forwarder")?, ), - Err(_) => Box::new( + // an empty address doesn't match the arm above so catch it here + // and handle it the same way as if it's missing altogether + Ok(_) | Err(_) => Box::new( LogForwarder::new(namespace) .await .context("new log forwarder")?,