Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-08 03:07:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-08 03:07:43 +0300
commit2b3bfe8fc59ed4cdc385955cdb38cbd481b45426 (patch)
tree6b570a8d134fb2beeacf11bbcc79ff22123156ec /app/workers/chat_notification_worker.rb
parentd203316c80aa27cf747aa29df9f7c2d374965b5f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers/chat_notification_worker.rb')
-rw-r--r--app/workers/chat_notification_worker.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/workers/chat_notification_worker.rb b/app/workers/chat_notification_worker.rb
index 42a23cd472a..6162dcf9d38 100644
--- a/app/workers/chat_notification_worker.rb
+++ b/app/workers/chat_notification_worker.rb
@@ -3,6 +3,9 @@
class ChatNotificationWorker
include ApplicationWorker
+ TimeoutExceeded = Class.new(StandardError)
+
+ sidekiq_options retry: false
feature_category :chatops
latency_sensitive_worker!
# TODO: break this into multiple jobs
@@ -11,18 +14,21 @@ class ChatNotificationWorker
# worker_has_external_dependencies!
RESCHEDULE_INTERVAL = 2.seconds
+ RESCHEDULE_TIMEOUT = 5.minutes
# rubocop: disable CodeReuse/ActiveRecord
- def perform(build_id)
+ def perform(build_id, reschedule_count = 0)
Ci::Build.find_by(id: build_id).try do |build|
send_response(build)
end
rescue Gitlab::Chat::Output::MissingBuildSectionError
+ raise TimeoutExceeded if timeout_exceeded?(reschedule_count)
+
# The creation of traces and sections appears to be eventually consistent.
# As a result it's possible for us to run the above code before the trace
# sections are present. To better handle such cases we'll just reschedule
# the job instead of producing an error.
- self.class.perform_in(RESCHEDULE_INTERVAL, build_id)
+ self.class.perform_in(RESCHEDULE_INTERVAL, build_id, reschedule_count + 1)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -37,4 +43,10 @@ class ChatNotificationWorker
end
end
end
+
+ private
+
+ def timeout_exceeded?(reschedule_count)
+ (reschedule_count * RESCHEDULE_INTERVAL) >= RESCHEDULE_TIMEOUT
+ end
end