Skip to content

Commit 906bd0f

Browse files
jokemanfiremxpv
authored andcommitted
Update publisher err deal.
ref:containerd/ttrpc-rust#259 Due to the inclusion of the latest version of ttrpc, this part of the code has been updated Signed-off-by: jokemanfire <[email protected]>
1 parent 559cc57 commit 906bd0f

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

crates/shim/src/asynchronous/publisher.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use containerd_shim_protos::{
2424
ttrpc,
2525
ttrpc::context::Context,
2626
};
27-
use log::debug;
27+
use log::{debug, error, warn};
2828
use tokio::sync::mpsc;
2929

3030
use crate::{
@@ -93,15 +93,20 @@ impl RemotePublisher {
9393
count: item.count + 1,
9494
};
9595
if let Err(e) = client.forward(new_item.ctx.clone(), &req).await {
96-
debug!("publish error {:?}", e);
97-
// This is a bug from ttrpc, ttrpc should return RemoteClosed|ClientClosed error. change it in future
98-
// if e == (ttrpc::error::Error::RemoteClosed || ttrpc::error::Error::ClientClosed)
99-
// reconnect client
100-
let new_client = Self::connect(address.as_str()).await.map_err(|e| {
101-
debug!("reconnect the ttrpc client {:?} fail", e);
102-
});
103-
if let Ok(c) = new_client {
104-
client = EventsClient::new(c);
96+
match e {
97+
ttrpc::error::Error::RemoteClosed | ttrpc::error::Error::LocalClosed => {
98+
warn!("publish fail because the server or client close {:?}", e);
99+
// reconnect client
100+
if let Ok(c) = Self::connect(address.as_str()).await.map_err(|e| {
101+
debug!("reconnect the ttrpc client {:?} fail", e);
102+
}) {
103+
client = EventsClient::new(c);
104+
}
105+
}
106+
_ => {
107+
// TODO! if it is other error , May we should deal with socket file
108+
error!("the client forward err is {:?}", e);
109+
}
105110
}
106111
let sender_ref = sender.clone();
107112
// Take a another task requeue , for no blocking the recv task

0 commit comments

Comments
 (0)