summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-01-14 22:33:48 -0800
committerStan Hu <stanhu@gmail.com>2019-01-15 00:15:40 -0800
commit6fbbd4ab393f0d56b8636b407a38273b4c77b3db (patch)
treecbea04eaf6149cd370ade6ee26ff095971cdb86f /app/workers
parent0e510780a15955b06445fb4c440230151da9ae93 (diff)
downloadgitlab-ce-6fbbd4ab393f0d56b8636b407a38273b4c77b3db.tar.gz
Only send one notification for failed remote mirror
Retries in Sidekiq and in the remote mirror scheduler can cause repeated attempts in quick succession if the sync fails. Each failure will then send an e-mail to all project maintainers, which can spam users unnecessarily. Modify the logic to send one notification the first time the mirror fails by setting `error_notification_sent` to `true` and reset the flag after a successful sync. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56222
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/remote_mirror_notification_worker.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/workers/remote_mirror_notification_worker.rb b/app/workers/remote_mirror_notification_worker.rb
index 70c2e857d09..5bafe8e2046 100644
--- a/app/workers/remote_mirror_notification_worker.rb
+++ b/app/workers/remote_mirror_notification_worker.rb
@@ -9,7 +9,10 @@ class RemoteMirrorNotificationWorker
# We check again if there's an error because a newer run since this job was
# fired could've completed successfully.
return unless remote_mirror && remote_mirror.last_error.present?
+ return if remote_mirror.error_notification_sent?
NotificationService.new.remote_mirror_update_failed(remote_mirror)
+
+ remote_mirror.after_sent_notification
end
end