diff --git a/examples/configmapgen_controller.rs b/examples/configmapgen_controller.rs index 18e9f96bc..9d2de5d5b 100644 --- a/examples/configmapgen_controller.rs +++ b/examples/configmapgen_controller.rs @@ -73,7 +73,11 @@ async fn reconcile(generator: Arc, ctx: Arc) -> Result } /// The controller triggers this on reconcile errors -fn error_policy(_object: Arc, _error: &Error, _ctx: Arc) -> Action { +fn error_policy(_object: Arc, error: &Error, _ctx: Arc) -> Action { + match error { + Error::ConfigMapCreationFailed(e) => warn!("cf creation failed: {e:?}"), + Error::MissingObjectKey(s) => warn!("missing key {s}"), + } Action::requeue(Duration::from_secs(1)) } diff --git a/kube-runtime/src/controller/mod.rs b/kube-runtime/src/controller/mod.rs index 409cd89e1..fa48993c3 100644 --- a/kube-runtime/src/controller/mod.rs +++ b/kube-runtime/src/controller/mod.rs @@ -41,9 +41,9 @@ pub type RunnerError = runner::Error; #[derive(Debug, Error)] pub enum Error { #[error("tried to reconcile object {0} that was not found in local store")] - ObjectNotFound(ObjectRef), + ObjectNotFound(Box>), #[error("reconciler for object {1} failed")] - ReconcilerFailed(#[source] ReconcilerErr, ObjectRef), + ReconcilerFailed(#[source] ReconcilerErr, Box>), #[error("event queue error")] QueueError(#[source] QueueErr), #[error("runner error")] @@ -332,7 +332,6 @@ const APPLIER_REQUEUE_BUF_SIZE: usize = 100; /// (such as triggering from arbitrary [`Stream`]s), at the cost of being a bit more verbose. #[allow(clippy::needless_pass_by_value)] #[allow(clippy::type_complexity)] -#[allow(clippy::result_large_err)] // see #1880 as an alt; https://github.com/kube-rs/kube/pull/1880 pub fn applier( mut reconciler: impl FnMut(Arc, Arc) -> ReconcilerFut, error_policy: impl Fn(Arc, &ReconcilerFut::Error, Arc) -> Action, @@ -412,8 +411,10 @@ where .instrument(reconciler_span) .left_future() } - None => std::future::ready(Err(Error::ObjectNotFound(request.obj_ref.erase()))) - .right_future(), + None => { + std::future::ready(Err(Error::ObjectNotFound(Box::new(request.obj_ref.erase())))) + .right_future() + } } }, ) @@ -432,7 +433,7 @@ where .and_then(move |(obj_ref, reconciler_result)| async move { match reconciler_result { Ok(action) => Ok((obj_ref, action)), - Err(err) => Err(Error::ReconcilerFailed(err, obj_ref.erase())), + Err(err) => Err(Error::ReconcilerFailed(err, Box::new(obj_ref.erase()))), } }) .on_complete(async { tracing::debug!("applier terminated") })