diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-05-31 16:12:20 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-06-06 17:49:48 +0900 |
commit | 3b569fceff09db6471a054128d2cbf268e63964d (patch) | |
tree | da7fe1603c4aeb543c420c8f79ee1f464954c10f /app/workers/ci | |
parent | ded38d5f48721b772fe23f3b7856c385f42b4fff (diff) | |
download | gitlab-ce-3b569fceff09db6471a054128d2cbf268e63964d.tar.gz |
Clean up worker
Diffstat (limited to 'app/workers/ci')
-rw-r--r-- | app/workers/ci/rescue_stale_live_trace_worker.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/workers/ci/rescue_stale_live_trace_worker.rb b/app/workers/ci/rescue_stale_live_trace_worker.rb new file mode 100644 index 00000000000..b60c212c468 --- /dev/null +++ b/app/workers/ci/rescue_stale_live_trace_worker.rb @@ -0,0 +1,23 @@ +module Ci + class RescueStaleLiveTraceWorker + include ApplicationWorker + include CronjobQueue + + def perform + # Reschedule to archive live traces + # + # The targets are jobs with the following conditions + # - It had been finished 1 hour ago, but it has not had an acthived trace yet + # This case happens when sidekiq-jobs of archiving traces are lost in order to restart sidekiq instace which hit RSS limit + Ci::BuildTraceChunk.find_stale(finished_before: 1.hour.ago) do |build_ids| + Ci::Build.where(id: build_ids).find_each do |build| + begin + build.trace.archive! + rescue => e + Rails.logger.info "Failed to archive stale live trace. id: #{build.id} message: #{e.message}" + end + end + end + end + end +end |