Skip to content

Commit a20ae57

Browse files
Merge pull request #106 from rh-amarin/HYPERFLEET-1011
HYPERFLEET-1011 - feat: simplify message decision engine
2 parents 9c306c7 + a7a4ab4 commit a20ae57

13 files changed

Lines changed: 288 additions & 416 deletions

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,20 @@ poll_interval: 5s
240240
241241
message_decision:
242242
params:
243-
ref_time: 'condition("Reconciled").last_updated_time'
244-
is_reconciled: 'condition("Reconciled").status == "True"'
245-
has_ref_time: 'ref_time != ""'
246-
is_new_resource: '!is_reconciled && resource.generation == 1'
247-
generation_mismatch: 'resource.generation > condition("Reconciled").observed_generation'
248-
reconciled_and_stale: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("30m")'
249-
not_reconciled_and_debounced: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("10s")'
243+
- name: ref_time
244+
expr: 'condition("Reconciled").last_updated_time'
245+
- name: is_reconciled
246+
expr: 'condition("Reconciled").status == "True"'
247+
- name: has_ref_time
248+
expr: 'ref_time != ""'
249+
- name: is_new_resource
250+
expr: '!is_reconciled && resource.generation == 1'
251+
- name: generation_mismatch
252+
expr: 'resource.generation > condition("Reconciled").observed_generation'
253+
- name: reconciled_and_stale
254+
expr: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("30m")'
255+
- name: not_reconciled_and_debounced
256+
expr: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("10s")'
250257
result: "is_new_resource || generation_mismatch || reconciled_and_stale || not_reconciled_and_debounced"
251258
252259
resource_selector:

charts/templates/configmap.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ data:
4949
message_decision:
5050
{{- if .Values.config.messageDecision.params }}
5151
params:
52-
{{- range $name, $expr := .Values.config.messageDecision.params }}
53-
{{ $name }}: {{ $expr | quote }}
52+
{{- range .Values.config.messageDecision.params }}
53+
- name: {{ .name }}
54+
expr: {{ .expr | quote }}
5455
{{- end }}
5556
{{- end }}
5657
result: {{ .Values.config.messageDecision.result | quote }}

charts/values.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,20 @@ config:
113113
# Result is a CEL boolean expression that determines whether to publish an event.
114114
messageDecision:
115115
params:
116-
ref_time: 'condition("Reconciled").last_updated_time'
117-
is_reconciled: 'condition("Reconciled").status == "True"'
118-
has_ref_time: 'ref_time != ""'
119-
is_new_resource: '!is_reconciled && resource.generation == 1'
120-
generation_mismatch: 'resource.generation > condition("Reconciled").observed_generation'
121-
reconciled_and_stale: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("30m")'
122-
not_reconciled_and_debounced: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("10s")'
116+
- name: ref_time
117+
expr: 'condition("Reconciled").last_updated_time'
118+
- name: is_reconciled
119+
expr: 'condition("Reconciled").status == "True"'
120+
- name: has_ref_time
121+
expr: 'ref_time != ""'
122+
- name: is_new_resource
123+
expr: '!is_reconciled && resource.generation == 1'
124+
- name: generation_mismatch
125+
expr: 'resource.generation > condition("Reconciled").observed_generation'
126+
- name: reconciled_and_stale
127+
expr: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("30m")'
128+
- name: not_reconciled_and_debounced
129+
expr: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("10s")'
123130
result: 'is_new_resource || generation_mismatch || reconciled_and_stale || not_reconciled_and_debounced'
124131

125132
# Resource selector for horizontal sharding

configs/dev-example.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,21 @@ poll_interval: 2s
5353
# Shorter debounce intervals for development.
5454
message_decision:
5555
params:
56-
ref_time: 'condition("Reconciled").last_updated_time'
57-
is_reconciled: 'condition("Reconciled").status == "True"'
58-
has_ref_time: 'ref_time != ""'
59-
is_new_resource: '!is_reconciled && resource.generation == 1'
60-
generation_mismatch: 'resource.generation > condition("Reconciled").observed_generation'
61-
reconciled_and_stale: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("2m")'
62-
not_reconciled_and_debounced: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("5s")'
63-
result: 'is_new_resource || generation_mismatch || reconciled_and_stale || not_reconciled_and_debounced'
56+
- name: ref_time
57+
expr: 'condition("Reconciled").last_updated_time'
58+
- name: is_reconciled
59+
expr: 'condition("Reconciled").status == "True"'
60+
- name: has_ref_time
61+
expr: 'ref_time != ""'
62+
- name: is_new_resource
63+
expr: '!is_reconciled && resource.generation == 1'
64+
- name: generation_mismatch
65+
expr: 'resource.generation > condition("Reconciled").observed_generation'
66+
- name: reconciled_and_stale
67+
expr: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("2m")'
68+
- name: not_reconciled_and_debounced
69+
expr: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("5s")'
70+
result: "is_new_resource || generation_mismatch || reconciled_and_stale || not_reconciled_and_debounced"
6471

6572
# Messaging system type for OpenTelemetry tracing attributes.
6673
# Should match the actual message broker being used for accurate observability.

configs/gcp-pubsub-example.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,20 @@ poll_interval: 5s
5252
# Uses condition-based checks with configurable thresholds.
5353
message_decision:
5454
params:
55-
ref_time: 'condition("Reconciled").last_updated_time'
56-
is_reconciled: 'condition("Reconciled").status == "True"'
57-
has_ref_time: 'ref_time != ""'
58-
is_new_resource: '!is_reconciled && resource.generation == 1'
59-
generation_mismatch: 'resource.generation > condition("Reconciled").observed_generation'
60-
reconciled_and_stale: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("30m")'
61-
not_reconciled_and_debounced: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("10s")'
55+
- name: ref_time
56+
expr: 'condition("Reconciled").last_updated_time'
57+
- name: is_reconciled
58+
expr: 'condition("Reconciled").status == "True"'
59+
- name: has_ref_time
60+
expr: 'ref_time != ""'
61+
- name: is_new_resource
62+
expr: '!is_reconciled && resource.generation == 1'
63+
- name: generation_mismatch
64+
expr: 'resource.generation > condition("Reconciled").observed_generation'
65+
- name: reconciled_and_stale
66+
expr: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("30m")'
67+
- name: not_reconciled_and_debounced
68+
expr: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("10s")'
6269
result: "is_new_resource || generation_mismatch || reconciled_and_stale || not_reconciled_and_debounced"
6370

6471
# Messaging system type for OpenTelemetry tracing attributes.

configs/rabbitmq-example.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,20 @@ poll_interval: 5s
5252
# Uses condition-based checks with configurable thresholds.
5353
message_decision:
5454
params:
55-
ref_time: 'condition("Reconciled").last_updated_time'
56-
is_reconciled: 'condition("Reconciled").status == "True"'
57-
has_ref_time: 'ref_time != ""'
58-
is_new_resource: '!is_reconciled && resource.generation == 1'
59-
generation_mismatch: 'resource.generation > condition("Reconciled").observed_generation'
60-
reconciled_and_stale: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("30m")'
61-
not_reconciled_and_debounced: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("10s")'
55+
- name: ref_time
56+
expr: 'condition("Reconciled").last_updated_time'
57+
- name: is_reconciled
58+
expr: 'condition("Reconciled").status == "True"'
59+
- name: has_ref_time
60+
expr: 'ref_time != ""'
61+
- name: is_new_resource
62+
expr: '!is_reconciled && resource.generation == 1'
63+
- name: generation_mismatch
64+
expr: 'resource.generation > condition("Reconciled").observed_generation'
65+
- name: reconciled_and_stale
66+
expr: 'is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("30m")'
67+
- name: not_reconciled_and_debounced
68+
expr: '!is_reconciled && has_ref_time && now - timestamp(ref_time) > duration("10s")'
6269
result: "is_new_resource || generation_mismatch || reconciled_and_stale || not_reconciled_and_debounced"
6370

6471
# Messaging system type for OpenTelemetry tracing attributes.

0 commit comments

Comments
 (0)