From 0b2a7b4823478ec470b5dfef6285ad6163cee2d9 Mon Sep 17 00:00:00 2001 From: Claus Matzinger Date: Thu, 19 Sep 2024 15:01:17 +0200 Subject: [PATCH] Empty NotificationGroups are not allowed (#148) fix: set notificationgroup to nil instead of empty --- controllers/alertmanagerconfig_controller.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/alertmanagerconfig_controller.go b/controllers/alertmanagerconfig_controller.go index d40ce40..1698853 100644 --- a/controllers/alertmanagerconfig_controller.go +++ b/controllers/alertmanagerconfig_controller.go @@ -257,7 +257,7 @@ func (r *AlertmanagerConfigReconciler) deleteWebhooksFromRelatedAlerts(ctx conte } for _, alert := range alerts.Items { - alert.Spec.NotificationGroups = []coralogixv1alpha1.NotificationGroup{{}} + alert.Spec.NotificationGroups = nil if err := r.Update(ctx, &alert); err != nil { return fmt.Errorf("received an error while trying to update Alert CRD from AlertmanagerConfig: %w", err) } @@ -315,7 +315,9 @@ func generateNotificationGroupFromRoutes(matchedRoutes []*prometheus.Route, matc notificationsGroups = append(notificationsGroups, notificationsGroup) } - + if len(notificationsGroups) == 0 { + return nil, nil + } return notificationsGroups, nil }