Skip to content

Commit

Permalink
Empty NotificationGroups are not allowed (#148)
Browse files Browse the repository at this point in the history
fix: set notificationgroup to nil instead of empty
  • Loading branch information
celaus authored Sep 19, 2024
1 parent ce4a7a0 commit 0b2a7b4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions controllers/alertmanagerconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -315,7 +315,9 @@ func generateNotificationGroupFromRoutes(matchedRoutes []*prometheus.Route, matc

notificationsGroups = append(notificationsGroups, notificationsGroup)
}

if len(notificationsGroups) == 0 {
return nil, nil
}
return notificationsGroups, nil
}

Expand Down

0 comments on commit 0b2a7b4

Please sign in to comment.