Skip to content

Commit

Permalink
add list of components that failed to shut down in time to panic msg
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-jiang committed Jan 9, 2025
1 parent 2fe231a commit ebafc38
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/topology/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl RunningTopology {
components = ?remaining_components,
"Failed to gracefully shut down in time. Killing components."
);
Result::Err(())
Result::Err(remaining_components)
}) as future::BoxFuture<'static, Result<(), ()>>
} else {
Box::pin(future::pending()) as future::BoxFuture<'static, Result<(), ()>>
Expand Down Expand Up @@ -195,18 +195,18 @@ impl RunningTopology {

// Aggregate future that ends once anything detects that all tasks have shutdown.
let shutdown_complete_future = future::select_all(vec![
Box::pin(timeout) as future::BoxFuture<'static, Result<(), ()>>,
Box::pin(reporter.map(|()| Result::<(), ()>::Ok(()))) as future::BoxFuture<'static, Result<(), ()>>,
Box::pin(success) as future::BoxFuture<'static, Result<(), ()>>,
Box::pin(timeout) as future::BoxFuture<'static, Result<(), String>>,
Box::pin(reporter.map(|()| Result::<(), String>::Ok(()))) as future::BoxFuture<'static, Result<(), String>>,
Box::pin(success) as future::BoxFuture<'static, Result<(), String>>,
]);

// Now kick off the shutdown process by shutting down the sources.
let source_shutdown_complete = self.shutdown_coordinator.shutdown_all(deadline).map(|_| Result::<(), ()>::Ok(()));
let source_shutdown_complete = self.shutdown_coordinator.shutdown_all(deadline).map(|_| Result::<(), String>::Ok(()));

// Panic to ensure that Vector returns a non-zero exit code when it's unable to gracefully shutdown
futures::future::join(source_shutdown_complete, shutdown_complete_future)
.map(|futures| match futures.1.0 {
Result::Err(_) => panic!("failed to gracefully shutdown in time, panic to force non-zero exit code"),
Result::Err(s) => panic!(format!("failed to gracefully shutdown in time, panic to force non-zero exit code: {s}")),
Result::Ok(_) => (),
})
}
Expand Down

0 comments on commit ebafc38

Please sign in to comment.