-
Notifications
You must be signed in to change notification settings - Fork 11
HYPERFLEET-537 - feat: refactor condition_rules to use CEL expressions #72
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,13 +18,22 @@ resource_type: clusters | |
| # Accepts Go duration format: ns, us/µs, ms, s, m, h. | ||
| poll_interval: 5s | ||
|
|
||
| # Max age interval for resources that are not ready. | ||
| # Resources in transitional states are re-checked more frequently. | ||
| max_age_not_ready: 10s | ||
|
|
||
| # Max age interval for resources that are ready and stable. | ||
| # Stable resources are checked less frequently to reduce API load. | ||
| max_age_ready: 30m | ||
| # Condition rules for decision making. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't found how are condition combined, is it AND or OR? |
||
| # Uses CEL expressions for flexible condition matching. | ||
| # | ||
| # Available CEL helper functions: | ||
| # condition(resource, type) → map - returns full condition map | ||
| # status(resource, type) → string - returns condition status | ||
| # conditionTime(resource, type) → string - returns last_updated_time (RFC3339) | ||
| conditions: | ||
| reference_time: 'conditionTime(resource, "Ready")' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is not clear to me what
In my mind, the CEL engine could be more generic.
One idea, but I think we should brainstorm this:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My proposal: trigger_decission:
- name: max_age
expression: 30m
- name: ready
expression: resource.conditions.filter(c, c.type=="Ready")[0]
- name: ref_time
expression: has(ready.last_updated_time )
? ready.last_updated_time
: ready.created_time
- name: operand1
expression: ready != "True"
result:
expression: operand1 AND operand2 AND (operand3 OR operand4)
reason:
expression: xxxxOR message_decision:
params:
max_age: 30m
ready: resource.conditions.filter(c, c.type=="Ready")[0]
ref_time: has(ready.last_updated_time )
? ready.last_updated_time
: ready.created_time
operand1: ready != "True"
result: operand1 AND operand2 AND (operand3 OR operand4) |
||
| rules: | ||
| - name: isReady | ||
| expression: 'status(resource, "Ready") == "True"' | ||
| max_age: 30m # Stable resources checked less frequently | ||
| - name: isNotReady | ||
| expression: 'status(resource, "Ready") == "False"' | ||
| max_age: 10s # Transitional resources re-checked more frequently | ||
|
|
||
| # Resource selector (optional) - filter resources by labels. | ||
| # If empty or omitted, all resources of the specified type are watched. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.