Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/configmapgen_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ async fn reconcile(generator: Arc<ConfigMapGenerator>, ctx: Arc<Data>) -> Result
}

/// The controller triggers this on reconcile errors
fn error_policy(_object: Arc<ConfigMapGenerator>, _error: &Error, _ctx: Arc<Data>) -> Action {
fn error_policy(_object: Arc<ConfigMapGenerator>, error: &Error, _ctx: Arc<Data>) -> Action {
match error {
Error::ConfigMapCreationFailed(e) => warn!("cf creation failed: {e:?}"),
Error::MissingObjectKey(s) => warn!("missing key {s}"),
}
Action::requeue(Duration::from_secs(1))
}

Expand Down
13 changes: 7 additions & 6 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ pub type RunnerError = runner::Error<reflector::store::WriterDropped>;
#[derive(Debug, Error)]
pub enum Error<ReconcilerErr: 'static, QueueErr: 'static> {
#[error("tried to reconcile object {0} that was not found in local store")]
ObjectNotFound(ObjectRef<DynamicObject>),
ObjectNotFound(Box<ObjectRef<DynamicObject>>),
#[error("reconciler for object {1} failed")]
ReconcilerFailed(#[source] ReconcilerErr, ObjectRef<DynamicObject>),
ReconcilerFailed(#[source] ReconcilerErr, Box<ObjectRef<DynamicObject>>),
#[error("event queue error")]
QueueError(#[source] QueueErr),
#[error("runner error")]
Expand Down Expand Up @@ -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<K, QueueStream, ReconcilerFut, Ctx>(
mut reconciler: impl FnMut(Arc<K>, Arc<Ctx>) -> ReconcilerFut,
error_policy: impl Fn(Arc<K>, &ReconcilerFut::Error, Arc<Ctx>) -> Action,
Expand Down Expand Up @@ -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()
}
}
},
)
Expand All @@ -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") })
Expand Down