From 954f4cef240866da2f7aa22d0c2d18a56f2cd958 Mon Sep 17 00:00:00 2001 From: Shirly Radco Date: Sun, 17 Aug 2025 17:13:02 +0300 Subject: [PATCH] Fix bug with CDIDataImportCronOutdated alert Updated CDIDataImportCronOutdated to fire only if the issue is related to the Pre-defined golden images. Add a CDIUserDefinedDataImportCronOutdated alert for user defined DIC that will not impact the operator health. Updated the namspabe label name fro ns to namespace, since each alert should report a namespace. Signed-off-by: Shirly Radco --- .../metrics/cdi-controller/dataimportcron.go | 2 +- pkg/monitoring/rules/alerts/operator.go | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/monitoring/metrics/cdi-controller/dataimportcron.go b/pkg/monitoring/metrics/cdi-controller/dataimportcron.go index 73a1581828..fe94afeacc 100644 --- a/pkg/monitoring/metrics/cdi-controller/dataimportcron.go +++ b/pkg/monitoring/metrics/cdi-controller/dataimportcron.go @@ -8,7 +8,7 @@ import ( const ( // PrometheusCronNsLabel labels the DataImportCron namespace - PrometheusCronNsLabel = "ns" + PrometheusCronNsLabel = "namespace" // PrometheusCronNameLabel labels the DataImportCron name PrometheusCronNameLabel = "cron_name" // PrometheusCronPendingLabel labels whether the DataImportCron import DataVolume is pending for default storage class diff --git a/pkg/monitoring/rules/alerts/operator.go b/pkg/monitoring/rules/alerts/operator.go index acd8ff1a1d..8bbe9ebf31 100644 --- a/pkg/monitoring/rules/alerts/operator.go +++ b/pkg/monitoring/rules/alerts/operator.go @@ -58,16 +58,28 @@ var operatorAlerts = []promv1.Rule{ }, { Alert: "CDIDataImportCronOutdated", - Expr: intstr.FromString(`sum by(ns,cron_name) (kubevirt_cdi_dataimportcron_outdated{pending="false"}) > 0`), + Expr: intstr.FromString(`sum by(namespace,cron_name) (kubevirt_cdi_dataimportcron_outdated{pending="false", namespace=~"openshift-virtualization-os-images|kubevirt-os-images"}) > 0`), For: (*promv1.Duration)(ptr.To("15m")), Annotations: map[string]string{ "summary": "DataImportCron (recurring polling of VM templates disk image sources, also known as golden images) PVCs are not being updated on the defined schedule", }, Labels: map[string]string{ - severityAlertLabelKey: "info", + severityAlertLabelKey: "warning", operatorHealthImpactLabelKey: "warning", }, }, + { + Alert: "CDIUserDefinedDataImportCronOutdated", + Expr: intstr.FromString(`sum by(namespace,cron_name) (kubevirt_cdi_dataimportcron_outdated{pending="false", namespace!~"openshift-virtualization-os-images|kubevirt-os-images"}) > 0`), + For: (*promv1.Duration)(ptr.To("15m")), + Annotations: map[string]string{ + "summary": "DataImportCron (recurring polling of VM templates disk image sources, also known as golden images) PVCs are not being updated on the defined schedule", + }, + Labels: map[string]string{ + severityAlertLabelKey: "warning", + operatorHealthImpactLabelKey: "none", + }, + }, { Alert: "CDINoDefaultStorageClass", Expr: intstr.FromString(`sum(kubevirt_cdi_storageprofile_info{default="true"} or on() vector(0)) +