diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2018-12-05 18:22:52 +0300 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2018-12-12 05:08:17 +0300 |
commit | b65cb237cee0b1a8dfdc21a09f2b181d0edf5bde (patch) | |
tree | dffc212c6e7ca84c1e61ec1625e53548c0b6de18 /app/models/remote_mirror.rb | |
parent | 80eebd8e33c5f2f26bc0fdd233d9d92c51edd242 (diff) |
Send a notification email on mirror update errors
The email is sent to project maintainers containing the last mirror
update error. This will allow maintainers to set alarms and react
accordingly.
Diffstat (limited to 'app/models/remote_mirror.rb')
-rw-r--r-- | app/models/remote_mirror.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/remote_mirror.rb b/app/models/remote_mirror.rb index b7b4d0f1be9..5a6895aefab 100644 --- a/app/models/remote_mirror.rb +++ b/app/models/remote_mirror.rb @@ -65,10 +65,14 @@ class RemoteMirror < ActiveRecord::Base ) end - after_transition started: :failed do |remote_mirror, _| + after_transition started: :failed do |remote_mirror| Gitlab::Metrics.add_event(:remote_mirrors_failed) remote_mirror.update(last_update_at: Time.now) + + remote_mirror.run_after_commit do + RemoteMirrorNotificationWorker.perform_async(remote_mirror.id) + end end end @@ -135,8 +139,8 @@ class RemoteMirror < ActiveRecord::Base end def mark_as_failed(error_message) - update_fail update_column(:last_error, Gitlab::UrlSanitizer.sanitize(error_message)) + update_fail end def url=(value) |