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

fix: handle fatal errors in dsp http dispatcher delegate #3203

Merged

Conversation

ndr-brt
Copy link
Member

@ndr-brt ndr-brt commented Jun 20, 2023

What this PR changes/adds

Add a new dispatch method on both RemoteMessageDispatcher and RemoteMessageDispatcherRegistry that return StatusResult, doing this it has been possible catch FATAL_ERRORs and avoid retry

Why it does that

avoid network pollution, improve error messaging

Further notes

From bottom to top:

  • changed the fallback used to call the http client, now it enable retry mechanism only if the status is not 2xx or 4xx (because client errors usually cannot be fixed by retry)
  • add the handleResponse method in DspHttpDispatcherDelegate that takes the place of parseResponse. It takes care to look at the status code and create the StatusResult accordingly, if response is successful, call parseResponse (that became protected)
  • on the state machine level, added the AsyncStatusResultRetryProcess class, that extends CompletableFutureRetryProcess and uses StatusResultRetryProcess to handle the StatusResult when the future succeeds.
  • the managers on fatal error will terminate the negotiation/transfer without sending anything to the counter-part.
  • the deprecated send methods on RemoteMessageDispatcher and RemoteMessageDispatcherRegistry are now unused, but I left them there to avoid compilation errors on downstream projects.

Linked Issue(s)

Closes #3202

Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.

@ndr-brt ndr-brt added bug Something isn't working dataspace-protocol related to the dataspace protocol labels Jun 20, 2023
@ndr-brt ndr-brt requested a review from wolf4ood June 20, 2023 14:08
* @param message the message
* @return a future that can be used to retrieve the response when the operation has completed
*/
<T, M extends RemoteMessage> CompletableFuture<StatusResult<T>> dispatch(Class<T> responseType, M message);

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'responseType' is never used.
@ndr-brt ndr-brt force-pushed the 3202-handle-message-failure branch from a05c604 to 63f4526 Compare June 20, 2023 14:21
}

@Nullable
private RemoteMessageDispatcher getDispatcher(@Nullable String protocol) {
if (protocol == null) {
Copy link
Member Author

@ndr-brt ndr-brt Jun 20, 2023

Choose a reason for hiding this comment

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

I removed this fallback dispatcher because I couldn't see its usefulness

@codecov-commenter
Copy link

codecov-commenter commented Jun 20, 2023

Codecov Report

Patch coverage: 82.95% and project coverage change: +0.04 🎉

Comparison is base (2e3ee8c) 65.59% compared to head (63f4526) 65.64%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3203      +/-   ##
==========================================
+ Coverage   65.59%   65.64%   +0.04%     
==========================================
  Files         836      841       +5     
  Lines       16811    16872      +61     
  Branches      926      928       +2     
==========================================
+ Hits        11028    11075      +47     
- Misses       5415     5428      +13     
- Partials      368      369       +1     
Impacted Files Coverage Δ
...core/base/RemoteMessageDispatcherRegistryImpl.java 20.00% <0.00%> (+5.71%) ⬆️
.../statemachine/retry/EntityRetryProcessFactory.java 0.00% <0.00%> (ø)
...lipse/edc/spi/message/RemoteMessageDispatcher.java 0.00% <0.00%> (ø)
...c/spi/message/RemoteMessageDispatcherRegistry.java 0.00% <0.00%> (ø)
...act/spi/types/negotiation/ContractNegotiation.java 0.00% <0.00%> (ø)
...dispatcher/DspHttpRemoteMessageDispatcherImpl.java 87.80% <16.66%> (-12.20%) ⬇️
.../dsp/spi/dispatcher/DspHttpDispatcherDelegate.java 54.16% <76.92%> (ø)
...temachine/retry/AsyncStatusResultRetryProcess.java 100.00% <100.00%> (ø)
...temachine/retry/CompletableFutureRetryProcess.java 100.00% <100.00%> (ø)
...g/eclipse/edc/statemachine/retry/RetryProcess.java 100.00% <100.00%> (ø)
... and 9 more

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ndr-brt ndr-brt changed the title feat: handle fatal errors in dsp http dispatcher delegate fix: handle fatal errors in dsp http dispatcher delegate Jun 20, 2023
Copy link
Contributor

@jimmarino jimmarino left a comment

Choose a reason for hiding this comment

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

Great stuff!

Copy link
Contributor

@wolf4ood wolf4ood left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Member

@paullatzelsperger paullatzelsperger left a comment

Choose a reason for hiding this comment

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

🧨

@paullatzelsperger paullatzelsperger merged commit 176aedd into eclipse-edc:main Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dataspace-protocol related to the dataspace protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A failed Negotiation request results in a termination message
5 participants