Commit 3de32dd2 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'move-worker-differences' into 'master'

Refactor Sidekiq workers to reduce differences between CE and EE

See merge request gitlab-org/gitlab-ce!24466
parents b061e896 4f623342
...@@ -9,14 +9,26 @@ class BuildFinishedWorker ...@@ -9,14 +9,26 @@ class BuildFinishedWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id) def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build| Ci::Build.find_by(id: build_id).try do |build|
# We execute that in sync as this access the files in order to access local file, and reduce IO process_build(build)
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
# Processes a single CI build that has finished.
#
# This logic resides in a separate method so that EE can extend it more
# easily.
#
# @param [Ci::Build] build The build to process.
def process_build(build)
# We execute these in sync to reduce IO.
BuildTraceSectionsWorker.new.perform(build.id) BuildTraceSectionsWorker.new.perform(build.id)
BuildCoverageWorker.new.perform(build.id) BuildCoverageWorker.new.perform(build.id)
# We execute that async as this are two independent operations that can be executed after TraceSections and Coverage # We execute these async as these are independent operations.
BuildHooksWorker.perform_async(build.id) BuildHooksWorker.perform_async(build.id)
ArchiveTraceWorker.perform_async(build.id) ArchiveTraceWorker.perform_async(build.id)
end end
end
# rubocop: enable CodeReuse/ActiveRecord
end end
...@@ -11,16 +11,9 @@ class ExpirePipelineCacheWorker ...@@ -11,16 +11,9 @@ class ExpirePipelineCacheWorker
pipeline = Ci::Pipeline.find_by(id: pipeline_id) pipeline = Ci::Pipeline.find_by(id: pipeline_id)
return unless pipeline return unless pipeline
project = pipeline.project
store = Gitlab::EtagCaching::Store.new store = Gitlab::EtagCaching::Store.new
store.touch(project_pipelines_path(project)) update_etag_cache(pipeline, store)
store.touch(project_pipeline_path(project, pipeline))
store.touch(commit_pipelines_path(project, pipeline.commit)) unless pipeline.commit.nil?
store.touch(new_merge_request_pipelines_path(project))
each_pipelines_merge_request_path(project, pipeline) do |path|
store.touch(path)
end
Gitlab::Cache::Ci::ProjectPipelineStatus.update_for_pipeline(pipeline) Gitlab::Cache::Ci::ProjectPipelineStatus.update_for_pipeline(pipeline)
end end
...@@ -51,4 +44,23 @@ class ExpirePipelineCacheWorker ...@@ -51,4 +44,23 @@ class ExpirePipelineCacheWorker
yield(path) yield(path)
end end
end end
# Updates ETag caches of a pipeline.
#
# This logic resides in a separate method so that EE can more easily extend
# it.
#
# @param [Ci::Pipeline] pipeline
# @param [Gitlab::EtagCaching::Store] store
def update_etag_cache(pipeline, store)
project = pipeline.project
store.touch(project_pipelines_path(project))
store.touch(project_pipeline_path(project, pipeline))
store.touch(commit_pipelines_path(project, pipeline.commit)) unless pipeline.commit.nil?
store.touch(new_merge_request_pipelines_path(project))
each_pipelines_merge_request_path(project, pipeline) do |path|
store.touch(path)
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment