diff --git a/crates/shim/src/synchronous/publisher.rs b/crates/shim/src/synchronous/publisher.rs index 508dc8e5..71449972 100644 --- a/crates/shim/src/synchronous/publisher.rs +++ b/crates/shim/src/synchronous/publisher.rs @@ -30,8 +30,12 @@ use crate::util::connect; use crate::{ error::Result, util::{convert_to_any, timestamp}, + Error, }; +#[cfg(windows)] +const RETRY_COUNT: i32 = 3; + /// Remote publisher connects to containerd's TTRPC endpoint to publish events from shim. pub struct RemotePublisher { client: EventsClient, @@ -59,10 +63,20 @@ impl RemotePublisher { #[cfg(windows)] { - match Client::connect(address.as_ref()) { - Ok(client) => Ok(client), - Err(e) => Err(e.into()), + for i in 0..RETRY_COUNT { + match Client::connect(address.as_ref()) { + Ok(client) => return Ok(client), + Err(e) => match e { + ttrpc::Error::Windows(231) => { + // ERROR_PIPE_BUSY + log::debug!("pipe busy during connect. try number {}", i); + std::thread::sleep(std::time::Duration::from_millis(5)); + } + _ => return Err(e.into()), + }, + } } + Err(other!("failed to connect to {}", address.as_ref())) } }