-
Notifications
You must be signed in to change notification settings - Fork 80
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
Remove easy-rules #540
base: main
Are you sure you want to change the base?
Remove easy-rules #540
Conversation
Have not looked but removing one layer of indirection that just adds security issues and a bunch of syntax sugar seems like a good idea. |
Can you ask in the maintainers group about any potential suggestion or preference for a rules engine |
2c476fc
to
e398d98
Compare
@@ -67,7 +67,6 @@ static Stream<String> provideRoutingRuleConfigFiles() | |||
String rulesDir = "src/test/resources/rules/"; | |||
return Stream.of( | |||
rulesDir + "routing_rules_atomic.yml", | |||
rulesDir + "routing_rules_composite.yml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR removes support for composite rules
de8b88e
to
d2d6bfa
Compare
d2d6bfa
to
3603a80
Compare
We should get that into 13 imho .. I wont be able to review this week before Friday |
18d7e42
to
206eab6
Compare
I agree to remove the unmaintained |
Do the rest of the examples and rules are supported by your 'MVEL adapter' How to check a user? can you give me an equivalent rule with the changes, I tried the below rule with your branch but could not get to work.
|
@vishalya it is tested with all the rules in https://github.com/willmostly/trino-gateway/tree/will/mvel-rules/gateway-ha/src/test/resources/rules. I think your issue is that |
gateway-ha/src/main/java/io/trino/gateway/ha/router/MVELFileRoutingGroupSelector.java
Outdated
Show resolved
Hide resolved
206eab6
to
efbe2d1
Compare
efbe2d1
to
fe0e040
Compare
fe0e040
to
e821140
Compare
@oneonestar ptal, I've refactored to remove abstractions for multi-engine support, with the exception of an interface to define the form of a rule. |
gateway-ha/src/main/java/io/trino/gateway/ha/router/FileBasedRoutingGroupSelector.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/FileBasedRoutingGroupSelector.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/FileBasedRoutingGroupSelector.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/MVELRoutingRule.java
Outdated
Show resolved
Hide resolved
e821140
to
edc723d
Compare
edc723d
to
7bde45b
Compare
Unrelated to this PR, but just want to raise a discussion: What would be an ideal way to verify these routing rules work? Ideally we want to test
Some of the core logic may depend on these routing rules, so it's essential to make sure they always work at CI/CD level... |
45d3356
to
fa054a2
Compare
@andythsu It's a good to have feature. You could open an issue to keep track of it. |
implements RoutingGroupSelector | ||
{ | ||
private static final Logger log = Logger.get(FileBasedRoutingGroupSelector.class); | ||
public static final String RESULTS_ROUTING_GROUP_KEY = "routingGroup"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent is for this to be used in routing rules so that users do not need to know this special string "routingGroup"
. I updated the rule files in the tests to demonstrate
gateway-ha/src/main/java/io/trino/gateway/ha/router/MVELRoutingRule.java
Outdated
Show resolved
Hide resolved
priority: 0 | ||
condition: "true" | ||
actions: | ||
- | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is - |
required, or is that some kind of coding style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -
indicates this is an array element, the |
indicates the beginning of a block scalar: https://github.com/yaml/yaml-grammar/blob/75083c2aaabd0d7453d72de895666b21021826c1/yaml-spec-1.2.txt#L1689
In this instance I'm using it because it allows me to avoid escaping all of the quotes in lines like
state.get("triggeredRules").contains("airflow") && request.getHeader("X-Trino-Client-Tags") contains "label=special"
fa054a2
to
d9aef12
Compare
Co-Authored-By: Prakhar Sapre <[email protected]>
d9aef12
to
72b1330
Compare
Description
Remove easy-rules and use mvel directly for rule evaluation This PR closes #527. The existing rule format is retained, with the exception that
easy-rules
style composite rules have been removed and replaced with astate
map that allows passing information between rule executions.Additional context and related issues
Trino Gateway currently leverages easy-rules to evaluate routing rules against an http request. This PR
The
MVELRoutingRule
andFileBasedRoutingGroupSelector
replicate the existing easy-rules functionality, minus composite rules. Easy-rules uses mvel as the execution engine, so rule condition and action syntax does not need to be migrated. This PR drops support for composite rules, which may be a breaking change for some users.An additional
state
object is made available to allow passing evaluation results from lower priority rules to higher priority rules. This should compensate for the removal of theeasy-rules
composite rules. For usage examples, see tests and docs.Database storage for MVEL rules will be added as a follow up.
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x ) Release notes are required, with the following suggested text:
Remove easy-rules library. Breaking change: composite rules are deprecated