Skip to content

Commit

Permalink
runtime-rs: fix handling of TTRCP_ADDRESS
Browse files Browse the repository at this point in the history
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 <pmores@redhat.com>
  • Loading branch information
pmores committed Feb 7, 2024
1 parent f0256fd commit 6346e04
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/runtime-rs/crates/service/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<dyn Forwarder>> {
let fwd: Box<dyn Forwarder> = 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")?,
Expand Down

0 comments on commit 6346e04

Please sign in to comment.