Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the object that failed in controller::Error::ReconcilerFailed #733

Merged
merged 1 commit into from
Nov 24, 2021
Merged
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
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>),
clux marked this conversation as resolved.
Show resolved Hide resolved
#[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