feat(notifications): send product notifications with a rights check right before each send

This commit is contained in:
shira committed 2026-10-09 20:38:39 +03:00
1 parent a856066316
commit 623d41b969
59 files changed
+4125 -1126

No files matched your search

+4 -3
View File
@@ -98,8 +98,9 @@ groups:
# loop starts. The rule fires only while at least one backend instance
# reports 1, so a stand without a transport stays silent. The age gauge
# counts only service mail (verification and password reset), the kinds
# the worker sends: a due notification awaits product notification sending and is not
# counted, so a notification backlog never fires this alert.
# the service worker sends. Product notifications have their own loop,
# lincodex_notification_sender_running, and are not counted here, so a
# notification backlog never fires this alert.
- alert: LincodexMailDeliveriesOverdue
expr: |
max(lincodex_mail_delivery_oldest_due_pending_age_seconds{job="backend"}) > 900
@@ -118,7 +119,7 @@ groups:
severity: warning
annotations:
summary: The mail sending worker cancelled a delivery because of a broken row or a repeated internal failure.
description: Reason content_invalid (the stored content does not match its hash, or the message is unsendable) or processing_failed (the worker failed on the row several times) is a defect or a manual edit, not a user action. Select id, kind, and cancel_reason from deliveries where status is cancelled and read the worker logs for the delivery_id. Cancellations that follow a user action (token_revoked, token_consumed, token_expired, account_not_current) are normal and do not fire this alert.
description: Reason content_invalid (the stored content does not match its hash, or the message is unsendable) or processing_failed (the worker failed on the row several times) is a defect or a manual edit, not a user action. Select id, kind, and cancel_reason from deliveries where status is cancelled and read the worker logs for the delivery_id. Cancellations that follow a user action or a rights change (token_revoked, token_consumed, token_expired, account_not_current, rights_revoked, recipient_ineligible, source_closed) are normal and do not fire this alert.
- alert: LincodexMailMetricsStale
expr: time() - max(lincodex_mail_metrics_last_success_timestamp_seconds{job="backend"}) > 300
@@ -279,17 +279,24 @@ tests:
severity: warning
exp_annotations:
summary: The mail sending worker cancelled a delivery because of a broken row or a repeated internal failure.
description: Reason content_invalid (the stored content does not match its hash, or the message is unsendable) or processing_failed (the worker failed on the row several times) is a defect or a manual edit, not a user action. Select id, kind, and cancel_reason from deliveries where status is cancelled and read the worker logs for the delivery_id. Cancellations that follow a user action (token_revoked, token_consumed, token_expired, account_not_current) are normal and do not fire this alert.
description: Reason content_invalid (the stored content does not match its hash, or the message is unsendable) or processing_failed (the worker failed on the row several times) is a defect or a manual edit, not a user action. Select id, kind, and cancel_reason from deliveries where status is cancelled and read the worker logs for the delivery_id. Cancellations that follow a user action or a rights change (token_revoked, token_consumed, token_expired, account_not_current, rights_revoked, recipient_ineligible, source_closed) are normal and do not fire this alert.
- eval_time: 35m
alertname: LincodexMailCancelledBroken
exp_alerts: []
- interval: 1m
# Reasons that follow a user action never fire it, however many there are.
# Reasons that follow a user action or a rights change never fire it, however
# many there are.
input_series:
- series: lincodex_mail_sender_cancelled_total{job="backend",instance="a",reason="token_revoked"}
values: 0+5x40
- series: lincodex_mail_sender_cancelled_total{job="backend",instance="a",reason="token_expired"}
values: 0+3x40
- series: lincodex_mail_sender_cancelled_total{job="backend",instance="a",reason="rights_revoked"}
values: 0+4x40
- series: lincodex_mail_sender_cancelled_total{job="backend",instance="a",reason="recipient_ineligible"}
values: 0+2x40
- series: lincodex_mail_sender_cancelled_total{job="backend",instance="a",reason="source_closed"}
values: 0+2x40
alert_rule_test:
- eval_time: 30m
alertname: LincodexMailCancelledBroken
@@ -306,7 +313,7 @@ tests:
severity: warning
exp_annotations:
summary: The mail sending worker cancelled a delivery because of a broken row or a repeated internal failure.
description: Reason content_invalid (the stored content does not match its hash, or the message is unsendable) or processing_failed (the worker failed on the row several times) is a defect or a manual edit, not a user action. Select id, kind, and cancel_reason from deliveries where status is cancelled and read the worker logs for the delivery_id. Cancellations that follow a user action (token_revoked, token_consumed, token_expired, account_not_current) are normal and do not fire this alert.
description: Reason content_invalid (the stored content does not match its hash, or the message is unsendable) or processing_failed (the worker failed on the row several times) is a defect or a manual edit, not a user action. Select id, kind, and cancel_reason from deliveries where status is cancelled and read the worker logs for the delivery_id. Cancellations that follow a user action or a rights change (token_revoked, token_consumed, token_expired, account_not_current, rights_revoked, recipient_ineligible, source_closed) are normal and do not fire this alert.
- interval: 1m
input_series:
- series: lincodex_mail_metrics_last_success_timestamp_seconds{job="backend",instance="a"}