Use the ClusterPeer interface from grafana/alerting (#61409)

* Use the Cluster interface from grafana/alerting
This commit is contained in:
gotjosh 2023-01-12 14:47:22 -04:00 committed by GitHub
parent 23dbc916e8
commit ddb85ad6ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

View File

@ -18,7 +18,6 @@ import (
"github.com/grafana/alerting/alerting"
"github.com/grafana/alerting/alerting/notifier/channels"
amv2 "github.com/prometheus/alertmanager/api/v2/models"
"github.com/prometheus/alertmanager/cluster"
"github.com/prometheus/alertmanager/config"
"github.com/prometheus/alertmanager/dispatch"
"github.com/prometheus/alertmanager/inhibit"
@ -31,7 +30,6 @@ import (
"github.com/prometheus/alertmanager/template"
"github.com/prometheus/alertmanager/timeinterval"
"github.com/prometheus/alertmanager/types"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
alertingModels "github.com/grafana/alerting/alerting/models"
@ -82,12 +80,6 @@ func init() {
}
}
type ClusterPeer interface {
AddState(string, cluster.State, prometheus.Registerer) cluster.ClusterChannel
Position() int
WaitReady(context.Context) error
}
type AlertingStore interface {
store.AlertingStore
store.ImageStore
@ -106,7 +98,7 @@ type Alertmanager struct {
marker types.Marker
alerts *mem.Alerts
route *dispatch.Route
peer ClusterPeer
peer alerting.ClusterPeer
peerTimeout time.Duration
dispatcher *dispatch.Dispatcher
@ -163,7 +155,7 @@ func (m maintenanceOptions) MaintenanceFunc(state alerting.State) (int64, error)
}
func newAlertmanager(ctx context.Context, orgID int64, cfg *setting.Cfg, store AlertingStore, kvStore kvstore.KVStore,
peer ClusterPeer, decryptFn channels.GetDecryptedValueFn, ns notifications.Service, m *metrics.Alertmanager) (*Alertmanager, error) {
peer alerting.ClusterPeer, decryptFn channels.GetDecryptedValueFn, ns notifications.Service, m *metrics.Alertmanager) (*Alertmanager, error) {
am := &Alertmanager{
Settings: cfg,
stopc: make(chan struct{}),

View File

@ -9,10 +9,7 @@ import (
"sync"
"time"
"github.com/grafana/grafana/pkg/services/ngalert/provisioning"
"github.com/grafana/grafana/pkg/services/notifications"
"github.com/grafana/grafana/pkg/services/secrets"
"github.com/grafana/alerting/alerting"
"github.com/grafana/alerting/alerting/notifier/channels"
"github.com/prometheus/alertmanager/cluster"
"github.com/prometheus/client_golang/prometheus"
@ -21,7 +18,10 @@ import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
"github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/provisioning"
"github.com/grafana/grafana/pkg/services/ngalert/store"
"github.com/grafana/grafana/pkg/services/notifications"
"github.com/grafana/grafana/pkg/services/secrets"
"github.com/grafana/grafana/pkg/setting"
)
@ -41,7 +41,7 @@ type MultiOrgAlertmanager struct {
logger log.Logger
// clusterPeer represents the clustering peers of Alertmanagers between Grafana instances.
peer ClusterPeer
peer alerting.ClusterPeer
settleCancel context.CancelFunc
configStore AlertingStore