summaryrefslogtreecommitdiff
path: root/app/models/remote_mirror.rb
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2018-12-05 12:22:52 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-12-11 23:08:17 -0300
commitb65cb237cee0b1a8dfdc21a09f2b181d0edf5bde (patch)
treedffc212c6e7ca84c1e61ec1625e53548c0b6de18 /app/models/remote_mirror.rb
parent80eebd8e33c5f2f26bc0fdd233d9d92c51edd242 (diff)
downloadgitlab-ce-b65cb237cee0b1a8dfdc21a09f2b181d0edf5bde.tar.gz
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.rb8
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)