Rescue APNs client errors instead of failing todo batches
What does this MR do and why?
Hardens Gitlab::MobilePush::ApnsClient#push so it never raises: connection
build and delivery errors are tracked via Gitlab::ErrorTracking and
reported as :failed (the outcome SendTodoNotificationsService already
counts and logs).
Previously, configured? only checked that the three APNs settings are
present — it never touched the filesystem. If mobile_push.apns.auth_key_path
pointed to a missing, unreadable, or invalid .p8 file, apnotic raised at
connection build (Cert file not found: …) inside
Todos::PushNotificationWorker, failing and retrying the batch job on every
todo creation for as long as the misconfiguration persisted — a permanent
Sidekiq failure/error-tracking storm from a config typo, with no push
delivered anyway.
With this change a misconfigured instance degrades to
mobile_push_notifications_total{result="failed"} counts plus one tracked
exception (grouped by Sentry), and todo batches complete normally.
Raised by @WarheadsSE while reviewing the Omnibus settings counterpart: omnibus-gitlab!9676 (comment 3688250767)
Distribution counterparts that catch the misconfiguration at configuration time (this MR is the runtime backstop):
- Omnibus: omnibus-gitlab!9676 (merged)
(reconfigure fails on partial
mobile_push_apns_*settings, warns on a missing key file) - Helm charts: gitlab-org/charts/gitlab!5257 (merged)
(
checkConfigfails rendering whenauth_keyis set withoutkey_id/team_id)
References
- Feature rollout issue: #607603
- APNs settings introduced in !248026 (merged)
How to set up and validate locally
- Configure
mobile_push.apnsinconfig/gitlab.ymlwithauth_key_pathpointing at a path that does not exist. - Enable the flags and create a todo (or run
Notifications::MobilePush::SendTodoNotificationsService.new([todo.id]).executefrom a console for a user with a device subscription). - Before: the worker raises
RuntimeError (Cert file not found: …)and retries. After: the service returns normally withapns_results: { "failed" => 1 }and the exception appears inlog/exceptions_json.log.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.