kube-rs / kube

Rust Kubernetes client and controller runtime
https://kube.rs
Apache License 2.0
3.03k stars 314 forks source link

Add error boundary wrapper type #1556

Closed nightkr closed 3 months ago

nightkr commented 3 months ago

Motivation

Fixes #774. In short, bulk requests (like Api::list and watcher) are currently unable to cope with failing to parse individual objects, and instead treat the whole list as failed.

Solution

This PR introduces a new wrapper type DeserializeGuard<T>, which can be used instead of Api<T> to opt into a more lenient style, where the list parse succeeds but each object reports errors separately.

Since it implements Resource, it should also work transparently for APIs building on top of Api<T>, such as Controller<T>.

Ideally, it'd be nice if at least Controller<T> would use it transparently, but that would mean a breaking change on the Controller types to take the right Api variant.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 64.10256% with 14 lines in your changes missing coverage. Please review.

Project coverage is 75.4%. Comparing base (4af4d80) to head (5a7cefa). Report is 1 commits behind head on main.

Files Patch % Lines
kube-core/src/error_boundary.rs 64.2% 14 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1556 +/- ## ======================================= - Coverage 75.6% 75.4% -0.1% ======================================= Files 79 80 +1 Lines 7237 7290 +53 ======================================= + Hits 5464 5495 +31 - Misses 1773 1795 +22 ``` | [Files](https://app.codecov.io/gh/kube-rs/kube/pull/1556?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kube-rs) | Coverage Δ | | |---|---|---| | [kube-core/src/error\_boundary.rs](https://app.codecov.io/gh/kube-rs/kube/pull/1556?src=pr&el=tree&filepath=kube-core%2Fsrc%2Ferror_boundary.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kube-rs#diff-a3ViZS1jb3JlL3NyYy9lcnJvcl9ib3VuZGFyeS5ycw==) | `64.2% <64.2%> (ø)` | | ... and [8 files with indirect coverage changes](https://app.codecov.io/gh/kube-rs/kube/pull/1556/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kube-rs)