diff options
author | Matthias Beyer <matthias.beyer@ifm.com> | 2022-09-15 08:47:26 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-09-15 08:50:56 +0200 |
commit | 4d0fc2e6c6c6b345bd2623986e458875795f240c (patch) | |
tree | 4e7ac747173083d4207da5db8280050570968394 | |
parent | d9a6a849687f508c1d2b9e87f40e69ea7e085bb7 (diff) |
Handle lifecycle errors at plugin shutdownpost-merge/core-reactor-lifecycle-error-propagation
This patch adds lifecycle-error handling during Plugin shutdown.
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r-- | crates/core/tedge_core/src/reactor.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/core/tedge_core/src/reactor.rs b/crates/core/tedge_core/src/reactor.rs index 21252537..2aa1de06 100644 --- a/crates/core/tedge_core/src/reactor.rs +++ b/crates/core/tedge_core/src/reactor.rs @@ -283,7 +283,7 @@ impl Reactor { .await; debug!("Running 'shutdown' for plugins"); - let _shutdown_results = all_plugins + let (_shutdown_results_ok, shutdown_results_err): (Vec<_>, Vec<_>) = all_plugins .iter_mut() .map(|plugin_task| { let span = @@ -293,7 +293,15 @@ impl Reactor { .collect::<futures::stream::FuturesOrdered<_>>() .collect::<Vec<Result<(), _>>>() .instrument(tracing::info_span!("core.mainloop.plugins.shutdown")) - .await; + .await + .into_iter() + .partition_result(); + + if !shutdown_results_err.is_empty() { + return Err(TedgeApplicationError::PluginLifecycleErrors { + errors: shutdown_results_err, + }); + } Ok(()) } |