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: implement policy-monitor #3456

Merged
merged 3 commits into from
Sep 26, 2023

Conversation

ndr-brt
Copy link
Member

@ndr-brt ndr-brt commented Sep 14, 2023

What this PR changes/adds

Implements the first version of the PolicyMonitor: embedded in the controlplane, with in-memory storage

Why it does that

streaming data transfer

Further notes

  • extracted a StateManager hierarchy, that permits to avoid some duplication, this can be pushed a little further, will do it in the subsequent PRs
  • the EndToEndKafkaTransferTest is showing the PolicyMonitor in action, defining a policy that expires in 10s, the transfer gets completed. there still is a missing part to actually shut down the data flow, described in this issue: policy-monitor: data flow should be stopped on transfer completion #3453
  • the InMemoryPolicyMonitorStore is not tested as it is a simple wrapper of the InMemoryStatefulEntityStore, tests will be added with the implementation of the Sql storage (policy-monitor: sql storage #3447 )

Linked Issue(s)

Closes #3445

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

@codecov-commenter
Copy link

codecov-commenter commented Sep 15, 2023

Codecov Report

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

Comparison is base (a3be9ed) 72.11% compared to head (b87ff07) 71.70%.

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3456      +/-   ##
==========================================
- Coverage   72.11%   71.70%   -0.41%     
==========================================
  Files         836      841       +5     
  Lines       16989    17002      +13     
  Branches      947      950       +3     
==========================================
- Hits        12252    12192      -60     
- Misses       4333     4407      +74     
+ Partials      404      403       -1     
Files Coverage Δ
.../edc/connector/contract/ContractCoreExtension.java 84.84% <ø> (ø)
...egotiation/AbstractContractNegotiationManager.java 100.00% <100.00%> (ø)
...iation/ConsumerContractNegotiationManagerImpl.java 100.00% <100.00%> (+1.16%) ⬆️
...iation/ProviderContractNegotiationManagerImpl.java 100.00% <100.00%> (+1.29%) ⬆️
...r/transfer/process/TransferProcessManagerImpl.java 94.94% <100.00%> (+1.49%) ⬆️
...taplane/framework/DataPlaneFrameworkExtension.java 85.00% <ø> (ø)
...aplane/framework/manager/DataPlaneManagerImpl.java 84.72% <100.00%> (-0.47%) ⬇️
...dc/connector/dataplane/util/sink/ParallelSink.java 46.34% <100.00%> (-2.50%) ⬇️
...licy/monitor/manager/PolicyMonitorManagerImpl.java 100.00% <100.00%> (ø)
.../edc/connector/transfer/TransferCoreExtension.java 0.00% <0.00%> (ø)
... and 6 more

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

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.

Looks good for a first iteration. I guess the larger issue of potentially missing additional data on the PolicyContext can be tackled in a subsequent iteration. Maybe that additional data could be persisted in a PolicyMonitorEntry?

.additional(ContractAgreement.class, contractAgreement)
.build();

var result = policyEngine.evaluate("transfer.process", policy, policyContext);
Copy link
Member

Choose a reason for hiding this comment

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

we already have that defined as constant on the ContractValidationService. Either we re-use that (possibly moving to a more common class), or we re-declare a constant here and annotate with @PolicyScope

Copy link
Member Author

Choose a reason for hiding this comment

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

will note this on my todo for the next PR 👍

@jimmarino jimmarino self-requested a review September 18, 2023 13:08
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.

Just a few minor things, particularly adding documentation to the classes.


import org.eclipse.edc.spi.persistence.StateEntityStore;

public interface PolicyMonitorStore extends StateEntityStore<PolicyMonitorEntry> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a dedicated store for that?
Can't we just browse the active ContractAgreement (i.e. not expired nor canceled) stored in the contract negotiation store?

Copy link
Member Author

@ndr-brt ndr-brt Sep 25, 2023

Choose a reason for hiding this comment

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

we need the state machine for reliability, scalability and performances (the reason was detailed in the related DR)

furthermore, ContractAgreements don't have an "expired" or "canceled" state, is a condition that needs to be verified on the policy, so otherwise we'd need to query every ContractAgreement every time as there's no way to mark them "expired" nor "canceled".

@ndr-brt ndr-brt merged commit 3fb0dc2 into eclipse-edc:main Sep 26, 2023
18 checks passed
@ndr-brt ndr-brt deleted the 3445-policy-monitor-embedded branch September 26, 2023 12:14
ndkrimbacher pushed a commit to nexyo-io/DataSpaceConnector that referenced this pull request Oct 4, 2023
* feat: implement policy-monitor

* Pull store to AbstractStateEntityManager

* PR remarks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core feature enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

policy-monitor: embedded implementation
6 participants