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

Add error boundary wrapper type #1556

Merged
merged 7 commits into from
Aug 7, 2024
Merged

Conversation

nightkr
Copy link
Member

@nightkr nightkr commented Aug 6, 2024

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.

Copy link

codecov bot commented Aug 6, 2024

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 ⚠️
Additional details and impacted files
@@           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 Coverage Δ
kube-core/src/error_boundary.rs 64.2% <64.2%> (ø)

... and 8 files with indirect coverage changes

@nightkr nightkr requested review from clux and a team August 6, 2024 11:36
@nightkr nightkr marked this pull request as ready for review August 6, 2024 11:54
Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cool! Took me a while to grok this, but it's a very nice non-breaking way to inject an opt-in error in here. Left some suggestions and a few minor questions, but no major complaints.

examples/errorbounded_configmap_watcher.rs Show resolved Hide resolved
kube-core/src/error_boundary.rs Outdated Show resolved Hide resolved
examples/errorbounded_configmap_watcher.rs Show resolved Hide resolved
kube-core/src/error_boundary.rs Show resolved Hide resolved
kube-core/src/error_boundary.rs Show resolved Hide resolved
kube-core/src/lib.rs Outdated Show resolved Hide resolved
@clux clux added the changelog-add changelog added category for prs label Aug 7, 2024
@clux clux added this to the 0.94.0 milestone Aug 7, 2024
Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good on my end.

@nightkr nightkr force-pushed the feature/error-boundary branch 2 times, most recently from 207faca to c5f6d68 Compare August 7, 2024 14:28
nightkr added 6 commits August 7, 2024 16:29
Fixes kube-rs#774

Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
@nightkr nightkr force-pushed the feature/error-boundary branch from c5f6d68 to 5a7cefa Compare August 7, 2024 14:29
@nightkr nightkr enabled auto-merge August 7, 2024 14:29
@nightkr nightkr merged commit f0f47af into kube-rs:main Aug 7, 2024
16 checks passed
@clux clux mentioned this pull request Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-add changelog added category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Watcher breaks if any object cannot be deserialized
2 participants