diff --git a/server/internal/scheduler/orchestrate/breaker.go b/server/internal/scheduler/orchestrate/breaker.go index 1aba7b4..46c7a04 100644 --- a/server/internal/scheduler/orchestrate/breaker.go +++ b/server/internal/scheduler/orchestrate/breaker.go @@ -9,6 +9,7 @@ import ( "github.com/redis/go-redis/v9" + "github.com/wangjia/pangolin/server/internal/alert" "github.com/wangjia/pangolin/server/internal/idgen" ) @@ -299,7 +300,9 @@ func (b *RedisBreaker) emitTripAlert(ctx context.Context, tier, region string, c "window_count", count, "threshold", threshold, ) if b.notifier != nil { - if err := b.notifier.NotifyFault(ctx, poolID, reason); err != nil { + event := alert.NewEvent(alert.EventTypeBreakerTripped, poolID, map[string]string{"reason": reason}) + event.Pool = poolID + if err := b.notifier.Notify(ctx, event); err != nil { slog.Error("breaker: emit trip alert failed", "pool", poolID, "error", err) } diff --git a/server/internal/scheduler/orchestrate/capacity.go b/server/internal/scheduler/orchestrate/capacity.go index dbea5b0..95babc0 100644 --- a/server/internal/scheduler/orchestrate/capacity.go +++ b/server/internal/scheduler/orchestrate/capacity.go @@ -7,6 +7,8 @@ import ( "time" "github.com/redis/go-redis/v9" + + "github.com/wangjia/pangolin/server/internal/alert" ) // ───────────────────────────────────────────────────────────────────────────── @@ -176,7 +178,9 @@ func (m *CapacityMonitor) checkWatermarks(ctx context.Context, cfg *SchedConfig) ) if m.notifier != nil { - if notifyErr := m.notifier.NotifyFault(ctx, poolID, reason); notifyErr != nil { + event := alert.NewEvent(alert.EventTypeWatermarkLow, "", map[string]string{"reason": reason}) + event.Pool = poolID + if notifyErr := m.notifier.Notify(ctx, event); notifyErr != nil { slog.Error("capacity: notify watermark alert", "pool", poolID, "error", notifyErr) } @@ -232,7 +236,8 @@ func (m *CapacityMonitor) checkProbeHeartbeats(ctx context.Context, cfg *SchedCo ) if m.notifier != nil { - if notifyErr := m.notifier.NotifyFault(ctx, probeNodeID, reason); notifyErr != nil { + event := alert.NewEvent(alert.EventTypeProbeAgentLost, probeNodeID, map[string]string{"reason": reason}) + if notifyErr := m.notifier.Notify(ctx, event); notifyErr != nil { slog.Error("capacity: notify probe lost contact", "probe_id", pid, "error", notifyErr) }