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

Remove alertID when alert not found #67

Merged
merged 2 commits into from
Jul 22, 2024
Merged
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
17 changes: 11 additions & 6 deletions internal/controllers/alertsconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ import (
"context"
"encoding/json"
"fmt"
"strings"

wf "github.com/WavefrontHQ/go-wavefront-management-api"
"github.com/go-logr/logr"
"github.com/google/uuid"
alertmanagerv1alpha1 "github.com/keikoproj/alert-manager/api/v1alpha1"
internalconfig "github.com/keikoproj/alert-manager/internal/config"
controllercommon "github.com/keikoproj/alert-manager/internal/controllers/common"
"github.com/keikoproj/alert-manager/internal/utils"
"github.com/keikoproj/alert-manager/pkg/log"
"github.com/keikoproj/alert-manager/pkg/wavefront"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"strings"

wf "github.com/WavefrontHQ/go-wavefront-management-api"
alertmanagerv1alpha1 "github.com/keikoproj/alert-manager/api/v1alpha1"
controllercommon "github.com/keikoproj/alert-manager/internal/controllers/common"
)

const (
Expand Down Expand Up @@ -189,6 +189,11 @@ func (r *AlertsConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request
if strings.Contains(err.Error(), "Exceeded limit setting") {
// For ex: error is "Exceeded limit setting: 100 alerts allowed per customer"
state = alertmanagerv1alpha1.ClientExceededLimit
} else if strings.Contains(err.Error(), "server returned 404 Not Found") {
alertStatus := alertsConfig.Status.AlertsStatus[alertName]
alertStatus.ID = ""
alertsConfig.Status.AlertsStatus[alertName] = alertStatus // Reset the ID
log.Error(err, "alert doesn't exist in wavefront, so reset alertID and create a new alert")
}
log.Error(err, "unable to create the alert")

Expand Down
Loading