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

Fixing bug recording rules finalizer #132

Merged
merged 3 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading