Skip to content
Open
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
42 changes: 29 additions & 13 deletions keep/api/bl/maintenance_windows_bl.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,10 @@ def recover_strategy(
"tenant_id": tenant,
},
)

incidents = []
with tracer.start_as_current_span("mw_recover_strategy_run_rules_engine"):
# Now we need to run the rules engine
if KEEP_CORRELATION_ENABLED:
incidents = []
try:
rules_engine = RulesEngine(tenant_id=tenant)
# handle incidents, also handle workflow execution as
Expand All @@ -275,17 +274,34 @@ def recover_strategy(
"tenant_id": tenant,
},
)
pusher_cache = get_notification_cache()
if incidents and pusher_cache.should_notify(tenant, "incident-change"):
pusher_client = get_pusher_client()
try:
pusher_client.trigger(
f"private-{tenant}",
"incident-change",
{},
)
except Exception:
logger.exception("Failed to tell the client to pull incidents")

with tracer.start_as_current_span("mw_recover_strategy_notify_client"):
pusher_client = get_pusher_client()
if not pusher_client:
return
pusher_cache = get_notification_cache()
if pusher_cache.should_notify(tenant, "poll-alerts"):
try:
pusher_client.trigger(
f"private-{tenant}",
"poll-alerts",
"{}",
)
logger.info("Told client to poll alerts")
except Exception:
logger.exception("Failed to tell client to poll alerts")
pass

if incidents and pusher_cache.should_notify(tenant, "incident-change"):
pusher_client = get_pusher_client()
try:
pusher_client.trigger(
f"private-{tenant}",
"incident-change",
{},
)
except Exception:
logger.exception("Failed to tell the client to pull incidents")

try:
presets = get_all_presets_dtos(tenant)
Expand Down
Loading