feat(mail): send service identity mail through a leased worker

This commit is contained in:
shira committed 2026-10-06 21:08:11 +03:00
1 parent 204c6bae62
commit d21fd49a42
58 files changed
+7577 -164

No files matched your search

@@ -199,6 +199,16 @@ tests:
- eval_time: 30m
alertname: LincodexMailDeliveriesOverdue
exp_alerts: []
- interval: 1m
input_series:
- series: lincodex_mail_delivery_oldest_due_pending_age_seconds{job="backend",instance="a"}
values: 2000x40
- series: lincodex_mail_sender_running{job="backend",instance="a"}
values: 0x40
alert_rule_test:
- eval_time: 30m
alertname: LincodexMailDeliveriesOverdue
exp_alerts: []
- interval: 1m
input_series:
- series: lincodex_mail_delivery_oldest_due_pending_age_seconds{job="backend",instance="a"}
@@ -215,8 +225,88 @@ tests:
- exp_labels:
severity: warning
exp_annotations:
summary: A pending mail delivery has been due for more than 15 minutes.
description: The sending worker runs but does not pick up due deliveries; check its logs and the quota gauges.
summary: A pending service mail delivery has been due for more than 15 minutes.
description: The sending worker runs but does not pick up due service mail (verification or password reset); check its logs and the quota gauges. Notifications are not counted.
- interval: 1m
input_series:
- series: lincodex_mail_delivery_oldest_due_pending_age_seconds{job="backend",instance="a"}
values: 2000x40
- series: lincodex_mail_sender_running{job="backend",instance="a"}
values: 0x40
- series: lincodex_mail_sender_running{job="backend",instance="b"}
values: 1x40
alert_rule_test:
- eval_time: 10m
alertname: LincodexMailDeliveriesOverdue
exp_alerts: []
- eval_time: 20m
alertname: LincodexMailDeliveriesOverdue
exp_alerts:
- exp_labels:
severity: warning
exp_annotations:
summary: A pending service mail delivery has been due for more than 15 minutes.
description: The sending worker runs but does not pick up due service mail (verification or password reset); check its logs and the quota gauges. Notifications are not counted.
- interval: 1m
# A backlog of notifications only: the sampler reports an age of 0 for
# service mail, so the alert stays silent although the sender runs and
# notifications are due.
input_series:
- series: lincodex_mail_delivery_oldest_due_pending_age_seconds{job="backend",instance="a"}
values: 0x40
- series: lincodex_mail_deliveries{job="backend",instance="a",kind="notification",status="pending"}
values: 500x40
- series: lincodex_mail_sender_running{job="backend",instance="a"}
values: 1x40
alert_rule_test:
- eval_time: 30m
alertname: LincodexMailDeliveriesOverdue
exp_alerts: []
- interval: 1m
input_series:
- series: lincodex_mail_sender_cancelled_total{job="backend",instance="a",reason="content_invalid"}
values: 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
- series: lincodex_mail_sender_cancelled_total{job="backend",instance="a",reason="token_revoked"}
values: 0+5x40
alert_rule_test:
- eval_time: 9m
alertname: LincodexMailCancelledBroken
exp_alerts: []
- eval_time: 12m
alertname: LincodexMailCancelledBroken
exp_alerts:
- exp_labels:
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.
- eval_time: 35m
alertname: LincodexMailCancelledBroken
exp_alerts: []
- interval: 1m
# Reasons that follow a user action 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
alert_rule_test:
- eval_time: 30m
alertname: LincodexMailCancelledBroken
exp_alerts: []
- interval: 1m
input_series:
- series: lincodex_mail_sender_cancelled_total{job="backend",instance="a",reason="processing_failed"}
values: 0 0 0 0 0 2x34
alert_rule_test:
- eval_time: 8m
alertname: LincodexMailCancelledBroken
exp_alerts:
- exp_labels:
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.
- interval: 1m
input_series:
- series: lincodex_mail_metrics_last_success_timestamp_seconds{job="backend",instance="a"}