Skip to content

Commit

Permalink
Include the object that failed in controller::Error::ReconcilerFailed
Browse files Browse the repository at this point in the history
Signed-off-by: Teo Klestrup Röijezon <teo@nullable.se>
  • Loading branch information
nightkr committed Nov 24, 2021
1 parent 7e2c102 commit de7cb4c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ UNRELEASED
* BREAKING: Added `kube::Error::NativeTls(kube::client::NativeTlsError)` for errors from Native TLS - #716
* BREAKING: Added `kube::Error::RustlsTls(kube::client::RustlsTlsError)` for errors from Rustls TLS - #704
* Updated `rustls` to 0.20.1 - #704
* BREAKING: Added `ObjectRef` to the object that failed to be reconciled to `kube_runtime::controller::Error::ReconcileFailed`

0.64.0 / 2021-11-16
===================
Expand Down
17 changes: 9 additions & 8 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ mod runner;

#[derive(Debug, Error)]
pub enum Error<ReconcilerErr: std::error::Error + 'static, QueueErr: std::error::Error + 'static> {
#[error("ObjectNotFound")]
#[error("tried to reconcile object {0} that was not found in local store")]
ObjectNotFound(ObjectRef<DynamicObject>),
#[error("ReconcilerFailed: {0}")]
ReconcilerFailed(#[source] ReconcilerErr),
#[error("SchedulerDequeueFailed: {0}")]
#[error("reconciler for object {1} failed")]
ReconcilerFailed(#[source] ReconcilerErr, ObjectRef<DynamicObject>),
#[error("scheduler dequeue failed")]
SchedulerDequeueFailed(#[source] scheduler::Error),
#[error("QueueError: {0}")]
#[error("event queue error")]
QueueError(#[source] QueueErr),
}

Expand Down Expand Up @@ -306,9 +306,10 @@ where
})
.await;
}
reconciler_result
.map(|action| (obj_ref, action))
.map_err(Error::ReconcilerFailed)
match reconciler_result {
Ok(action) => Ok((obj_ref, action)),
Err(err) => Err(Error::ReconcilerFailed(err, obj_ref.erase()))
}
}
})
.on_complete(async { tracing::debug!("applier terminated") })
Expand Down
2 changes: 1 addition & 1 deletion kube/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ mod test {
let gvk = GroupVersionKind::gvk("clux.dev", "v1", "Foo");
let api_resource = ApiResource::from_gvk(&gvk);
let a1: Api<DynamicObject> = Api::namespaced_with(client.clone(), "myns", &api_resource);
let a2: Api<Foo> = Api::namespaced(client.clone(), "myns");
let a2: Api<Foo> = Api::namespaced(client, "myns");

// make sure they return the same url_path through their impls
assert_eq!(a1.resource_url(), a2.resource_url());
Expand Down

0 comments on commit de7cb4c

Please sign in to comment.