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

feat: add DataAddressValidatorRegistry #3570

Merged
merged 3 commits into from Oct 29, 2023

Conversation

ndr-brt
Copy link
Member

@ndr-brt ndr-brt commented Oct 26, 2023

What this PR changes/adds

This PR seems larger than how it is, just because some file movements and renaming

Implement DataAddressValidatorRegistry, that is used by the aggregated services to ensure that source/destination DataAddresses are valid

Why it does that

Assets (provider side) or TransferProcesses (consumer side) should not being created if their addresses are not valid.

Further notes

  • if the DataAddress type is not registed on the registry the validation will pass but logging a warning message, because validation definitely needs to be in place but it should not block already working flows.
  • by default the connector register basic data address types as HttpData, HttpProxy and Kafka
  • the dataplane extensions use the new validator instances to validate the address but not formally: a nice idea could be to have the DataAddressValidatorRegistry as collaborator of the DataPlaneManager, so every request would be validated with the same validator (leaving to the sink/source factories validate method only custom validations)
  • HttpDataAddress has been moved to data-plane-http-spi, as it is a type used specifically in the data-plane, no real use in the control plane

Linked Issue(s)

Closes #3557

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

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.

Before going further, let's discuss the comment inline

import static org.eclipse.edc.spi.dataaddress.KafkaDataAddressSchema.TOPIC;
import static org.eclipse.edc.validator.spi.Violation.violation;

public class KafkaDataAddressValidator implements Validator<DataAddress> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think Kafka-specific classes should go into a core module. Can we either move this out or make it a generic messaging validator that can be configured? For example, I don't think this class is necessarily specific to Kafka since it could be used with any messaging platform that supports topics (pub/sub) or queues.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can agree with this, I wanted to understand how deep to go with the refactoring.

Likely, every data type should have its own Schema interface (for now they are both in the core-spi modules) and a Validator implementation (that currently I put in the validator-core module).

Splitting this vertically, we could end up having, for every DataAddress type, an spi and a validator extension, like:
dataaddress-httpdata-spi - validator-dataaddress-httpdata
and
dataaddress-kafka-spi - validator-dataaddress-kafka

with the spi containing only the Schema interface and the validator containing the Validator implementation and the registration extension.

wdyt @jimmarino ?

Copy link
Contributor

Choose a reason for hiding this comment

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

That works for me. One relly minor nit would be to use "data-address" as opposed to "dataadress" since it is easier to read, but that is only a minor suggestion.

@codecov-commenter
Copy link

codecov-commenter commented Oct 27, 2023

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (26a6f4e) 72.35% compared to head (46474a1) 72.19%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3570      +/-   ##
==========================================
- Coverage   72.35%   72.19%   -0.17%     
==========================================
  Files         889      889              
  Lines       17781    17814      +33     
  Branches     1016     1015       -1     
==========================================
- Hits        12866    12860       -6     
- Misses       4479     4516      +37     
- Partials      436      438       +2     
Files Coverage Δ
...c/connector/core/CoreDefaultServicesExtension.java 75.00% <ø> (ø)
...ipse/edc/connector/core/CoreServicesExtension.java 94.73% <100.00%> (+0.14%) ⬆️
...re/validator/DataAddressValidatorRegistryImpl.java 100.00% <100.00%> (ø)
...nnector/service/ControlPlaneServicesExtension.java 100.00% <ø> (ø)
...ferprocess/TransferProcessProtocolServiceImpl.java 98.91% <100.00%> (ø)
...ce/transferprocess/TransferProcessServiceImpl.java 89.47% <100.00%> (ø)
...address/httpdata/HttpDataDataAddressValidator.java 100.00% <100.00%> (ø)
...ector/provision/http/HttpProvisionerExtension.java 88.23% <100.00%> (+0.73%) ⬆️
...sfer/dataplane/TransferDataPlaneCoreExtension.java 82.60% <100.00%> (+0.79%) ⬆️
.../http/oauth2/Oauth2HttpRequestParamsDecorator.java 100.00% <ø> (ø)
... and 14 more

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Two small doc requests if you have time to put in before merging

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.

LGTM!

@ndr-brt ndr-brt merged commit 68a5fd5 into eclipse-edc:main Oct 29, 2023
17 checks passed
@ndr-brt ndr-brt deleted the 3557-data-address-validator branch October 29, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make DataAddressValidator works also for other data address types
4 participants