Skip to content

Commit

Permalink
Fixing bug recording rules finalizer (#132)
Browse files Browse the repository at this point in the history
* fixing bug_recording-rules finalizer
  • Loading branch information
OrNovo authored Aug 11, 2024
1 parent c054465 commit ff9d00c
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (r *RecordingRuleGroupSetReconciler) delete(ctx context.Context, recordingR
return fmt.Errorf("failed to delete recording rule groupSet: %w", err)
}

controllerutil.RemoveFinalizer(recordingRuleGroupSet, alertFinalizerName)
controllerutil.RemoveFinalizer(recordingRuleGroupSet, recordingRuleGroupSetFinalizerName)
if err = r.Update(ctx, recordingRuleGroupSet); err != nil {
return fmt.Errorf("failed to remove finalizer from recording rule groupSet: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: coralogix.com/v1alpha1
kind: RecordingRuleGroupSet
metadata:
name: prometheus-example-rules
status:
spec:
groups:
- intervalSeconds: 60
name: example.rules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
expr: vector(1)
- record: ExampleRecord2
expr: vector(2)
- alert: app-latency
- alert: app-latency-1
expr: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) by (le, destination_workload)) > 0.2
for: 5m
annotations:
Expand All @@ -27,7 +27,7 @@ spec:
expr: vector(3)
- record: ExampleRecord
expr: vector(4)
- alert: app-latency
- alert: app-latency-2
expr: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) by (le, destination_workload)) > 0.2
for: 5m
annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
- alert.coralogix.com/finalizer
labels:
app.kubernetes.io/managed-by: prometheus-example-rules
name: prometheus-example-rules-app-latency-0
name: prometheus-example-rules-app-latency-1
namespace: default
ownerReferences:
- apiVersion: monitoring.coreos.com/v1
Expand All @@ -24,12 +24,9 @@ status:
timeWindow: FiveMinutes
searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m]))
by (le, destination_workload)) > 0.2
name: app-latency
name: app-latency-1
notificationGroups:
- notifications:
- notifyOn: TriggeredOnly
retriggeringPeriodMinutes: 5
severity: Critical
showInInsight:
notifyOn: TriggeredOnly
retriggeringPeriodMinutes: 5
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
- alert.coralogix.com/finalizer
labels:
app.kubernetes.io/managed-by: prometheus-example-rules
name: prometheus-example-rules-app-latency-1
name: prometheus-example-rules-app-latency-2
namespace: default
ownerReferences:
- apiVersion: monitoring.coreos.com/v1
Expand All @@ -24,12 +24,9 @@ status:
timeWindow: FiveMinutes
searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m]))
by (le, destination_workload)) > 0.2
name: app-latency
name: app-latency-2
notificationGroups:
- notifications:
- notifyOn: TriggeredOnly
retriggeringPeriodMinutes: 5
severity: Info
showInInsight:
notifyOn: TriggeredOnly
retriggeringPeriodMinutes: 5
20 changes: 20 additions & 0 deletions tests/e2e/promatheusrules/basic/03-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: coralogix.com/v1alpha1
kind: RecordingRuleGroupSet
metadata:
name: prometheus-example-rules
spec:
groups:
- intervalSeconds: 70
name: example.rules2
rules:
- expr: vector(3)
record: UpdatedExampleRecord
- expr: vector(4)
record: UpdatedExampleRecord
- intervalSeconds: 60
name: example.rules
rules:
- expr: vector(1)
record: UpdatedExampleRecord
- expr: vector(2)
record: UpdatedExampleRecord2
36 changes: 36 additions & 0 deletions tests/e2e/promatheusrules/basic/03-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
labels:
app.coralogix.com/track-recording-rules: "true"
app.coralogix.com/track-alerting-rules: "true"
name: prometheus-example-rules
spec:
groups:
- name: example.rules2
interval: "70s"
rules:
- record: UpdatedExampleRecord
expr: vector(3)
- record: UpdatedExampleRecord
expr: vector(4)
- alert: updated-app-latency-1
expr: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) by (le, destination_workload)) > 0.2
for: 15m
annotations:
cxMinNonNullValuesPercentage: "25"
labels:
severity: info
- name: example.rules
rules:
- record: UpdatedExampleRecord
expr: vector(1)
- record: UpdatedExampleRecord2
expr: vector(2)
- alert: updated-app-latency-2
expr: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m])) by (le, destination_workload)) > 0.2
for: 5m
annotations:
cxMinNonNullValuesPercentage: "25"
labels:
severity: critical
32 changes: 32 additions & 0 deletions tests/e2e/promatheusrules/basic/04-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: coralogix.com/v1alpha1
kind: Alert
metadata:
finalizers:
- alert.coralogix.com/finalizer
labels:
app.kubernetes.io/managed-by: prometheus-example-rules
name: prometheus-example-rules-updated-app-latency-1
namespace: default
ownerReferences:
- apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
name: prometheus-example-rules
status:
active: true
alertType:
metric:
promql:
conditions:
alertWhen: More
minNonNullValuesPercentage: 0
sampleThresholdPercentage: 100
threshold: "0"
timeWindow: FifteenMinutes
searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m]))
by (le, destination_workload)) > 0.2
name: updated-app-latency-1
notificationGroups:
- notifications:
- notifyOn: TriggeredOnly
retriggeringPeriodMinutes: 15
severity: Info
32 changes: 32 additions & 0 deletions tests/e2e/promatheusrules/basic/05-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: coralogix.com/v1alpha1
kind: Alert
metadata:
finalizers:
- alert.coralogix.com/finalizer
labels:
app.kubernetes.io/managed-by: prometheus-example-rules
name: prometheus-example-rules-updated-app-latency-2
namespace: default
ownerReferences:
- apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
name: prometheus-example-rules
status:
active: true
alertType:
metric:
promql:
conditions:
alertWhen: More
minNonNullValuesPercentage: 0
sampleThresholdPercentage: 100
threshold: "0"
timeWindow: FiveMinutes
searchQuery: histogram_quantile(0.99, sum(irate(istio_request_duration_seconds_bucket{reporter="source",destination_service=~"ingress-annotation-test-svc.example-app.svc.cluster.local"}[1m]))
by (le, destination_workload)) > 0.2
name: updated-app-latency-2
notificationGroups:
- notifications:
- notifyOn: TriggeredOnly
retriggeringPeriodMinutes: 5
severity: Critical
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: coralogix.com/v1alpha1
kind: Alert
metadata:
name: prometheus-example-rules-app-latency-0
name: prometheus-example-rules-app-latency-2
File renamed without changes.

0 comments on commit ff9d00c

Please sign in to comment.