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

NETOBSERV-976 Fix disabling alerts #328

Merged
merged 1 commit into from
Apr 27, 2023
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
7 changes: 5 additions & 2 deletions controllers/flowcollector_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ func flowCollectorControllerSpecs() {
Duration: conntrackEndTimeout,
},
Metrics: flowslatest.FLPMetrics{
IgnoreTags: []string{"flows", "bytes", "packets"},
IgnoreTags: []string{"flows", "bytes", "packets"},
DisableAlerts: []flowslatest.FLPAlert{flowslatest.AlertLokiError},
},
}
fc.Spec.Loki = flowslatest.FlowCollectorLoki{}
Expand Down Expand Up @@ -396,13 +397,15 @@ func flowCollectorControllerSpecs() {
}, &sm)
}, timeout, interval).Should(Succeed())

By("Expecting PrometheusRule to exist")
By("Expecting PrometheusRule to exist and be updated")
Eventually(func() interface{} {
return k8sClient.Get(ctx, types.NamespacedName{
Name: "flowlogs-pipeline-alert",
Namespace: operatorNamespace,
}, &pr)
}, timeout, interval).Should(Succeed())
Expect(pr.Spec.Groups).Should(HaveLen(1))
Expect(pr.Spec.Groups[0].Rules).Should(HaveLen(1))

// Manually delete ServiceMonitor
By("Deleting ServiceMonitor")
Expand Down
2 changes: 1 addition & 1 deletion controllers/flowlogspipeline/flp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func TestPrometheusRuleChanged(t *testing.T) {
b := newMonolithBuilder("namespace", image, &cfg, true)
first := b.generic.prometheusRule()

// Check namespace change
// Check enabled rule change
cfg.Processor.Metrics.DisableAlerts = []flowslatest.FLPAlert{flowslatest.AlertNoFlows}
b = newMonolithBuilder("namespace", image, &cfg, true)
second := b.generic.prometheusRule()
Expand Down
3 changes: 2 additions & 1 deletion pkg/helper/comparators.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ func ServiceMonitorChanged(old, new *monitoringv1.ServiceMonitor, report *Change
}

func PrometheusRuleChanged(old, new *monitoringv1.PrometheusRule, report *ChangeReport) bool {
return report.Check("PrometheusRule spec changed", !equality.Semantic.DeepDerivative(new.Spec, old.Spec)) ||
// Note: DeepDerivative misses changes in Spec.Groups.Rules (covered by test "Expecting PrometheusRule to exist and be updated")
return report.Check("PrometheusRule spec changed", !equality.Semantic.DeepEqual(new.Spec, old.Spec)) ||
report.Check("PrometheusRule labels changed", !IsSubSet(old.Labels, new.Labels))
}

Expand Down