diff options
author | Stan Hu <stanhu@gmail.com> | 2019-01-14 22:33:48 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-01-15 00:15:40 -0800 |
commit | 6fbbd4ab393f0d56b8636b407a38273b4c77b3db (patch) | |
tree | cbea04eaf6149cd370ade6ee26ff095971cdb86f /app/models/remote_mirror.rb | |
parent | 0e510780a15955b06445fb4c440230151da9ae93 (diff) | |
download | gitlab-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/models/remote_mirror.rb')
-rw-r--r-- | app/models/remote_mirror.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/remote_mirror.rb b/app/models/remote_mirror.rb index a3fa67c72bf..5eba7ddd75c 100644 --- a/app/models/remote_mirror.rb +++ b/app/models/remote_mirror.rb @@ -61,7 +61,10 @@ class RemoteMirror < ActiveRecord::Base timestamp = Time.now remote_mirror.update!( - last_update_at: timestamp, last_successful_update_at: timestamp, last_error: nil + last_update_at: timestamp, + last_successful_update_at: timestamp, + last_error: nil, + error_notification_sent: false ) end @@ -179,6 +182,10 @@ class RemoteMirror < ActiveRecord::Base project.repository.add_remote(remote_name, remote_url) end + def after_sent_notification + update_column(:error_notification_sent, true) + end + private def store_credentials @@ -221,7 +228,8 @@ class RemoteMirror < ActiveRecord::Base last_error: nil, last_update_at: nil, last_successful_update_at: nil, - update_status: 'finished' + update_status: 'finished', + error_notification_sent: false ) end |