Skip alert if it's not ready

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan 2020-11-09 14:30:33 +02:00
parent 6c855a22bc
commit 9ba52a45e5
No known key found for this signature in database
GPG Key ID: 3299AEB0E4085BAF
2 changed files with 8 additions and 2 deletions

View File

@ -127,6 +127,11 @@ func (r *AlertReconciler) validate(ctx context.Context, alert v1beta1.Alert) err
if err := r.Get(ctx, providerName, &provider); err != nil {
return fmt.Errorf("failed to get provider %s, error: %w", providerName.String(), err)
}
if !meta.HasReadyCondition(provider.Status.Conditions) {
return fmt.Errorf("provider %s is not ready", providerName.String())
}
return nil
}

View File

@ -26,6 +26,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/recorder"
"github.com/fluxcd/notification-controller/api/v1beta1"
@ -64,8 +65,8 @@ func (s *EventServer) handleEvent() func(w http.ResponseWriter, r *http.Request)
// find matching alerts
alerts := make([]v1beta1.Alert, 0)
for _, alert := range allAlerts.Items {
// skip suspended alerts
if alert.Spec.Suspend {
// skip suspended and not ready alerts
if alert.Spec.Suspend || !meta.HasReadyCondition(alert.Status.Conditions) {
continue
}