diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-07-17 22:38:37 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-07-17 22:38:37 +0800 |
commit | 65e722ee977a3fcd44fb272aa716dfa679385759 (patch) | |
tree | 3fee24a0e09670909df47163fc8d97fb2cc6380d /app/workers | |
parent | 550ccf443059412a26adfcba15fbe9d05d39a5f9 (diff) | |
parent | 05329d4a364a5c55f2de9546871de1909b6be3f5 (diff) | |
download | gitlab-ce-65e722ee977a3fcd44fb272aa716dfa679385759.tar.gz |
Merge remote-tracking branch 'upstream/master' into 30634-protected-pipeline
* upstream/master: (638 commits)
Simplify background migrations stealing code
Expire cached user IDs that can see the performance after 5 minutes
Promote visibility level helpers from Group to Namespace
Fix off-by-one error in background migration retries
Recover from all exceptions when stealing bg migration
Fix label creation from new list for subgroup projects
move click handler to button. when on the icon it wasn't triggered in firefox
Fix incorrect AWS ELB metrics.
Fix wrong link to docs in docs styleguide
Update issue-related docs
Refactor groups docs
Add subgroups limitations to Pages docs
Update Google launcher details
Split docs on IP whitelist for monitoring access
Update health check docs
Bump fog-core to 1.44.3 and fog providers' plugins to latest
Introduce have_gitlab_http_status
Remove Repository#search_files
Update Pipeline's badge count in Merge Request and Commits view to match real-time content
Fixes the user order being overriden in the autocomplete controller
...
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/background_migration_worker.rb | 20 | ||||
-rw-r--r-- | app/workers/expire_job_cache_worker.rb | 12 | ||||
-rw-r--r-- | app/workers/expire_pipeline_cache_worker.rb | 28 |
3 files changed, 25 insertions, 35 deletions
diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb index e85e221d353..45ce49bb5c0 100644 --- a/app/workers/background_migration_worker.rb +++ b/app/workers/background_migration_worker.rb @@ -2,18 +2,34 @@ class BackgroundMigrationWorker include Sidekiq::Worker include DedicatedSidekiqQueue - # Schedules a number of jobs in bulk + # Enqueues a number of jobs in bulk. # # The `jobs` argument should be an Array of Arrays, each sub-array must be in # the form: # # [migration-class, [arg1, arg2, ...]] - def self.perform_bulk(*jobs) + def self.perform_bulk(jobs) Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => jobs) end + # Schedules multiple jobs in bulk, with a delay. + # + def self.perform_bulk_in(delay, jobs) + now = Time.now.to_i + schedule = now + delay.to_i + + if schedule <= now + raise ArgumentError, 'The schedule time must be in the future!' + end + + Sidekiq::Client.push_bulk('class' => self, + 'queue' => sidekiq_options['queue'], + 'args' => jobs, + 'at' => schedule) + end + # Performs the background migration. # # See Gitlab::BackgroundMigration.perform for more information. diff --git a/app/workers/expire_job_cache_worker.rb b/app/workers/expire_job_cache_worker.rb index 08e281e7350..e383202260d 100644 --- a/app/workers/expire_job_cache_worker.rb +++ b/app/workers/expire_job_cache_worker.rb @@ -18,18 +18,10 @@ class ExpireJobCacheWorker private def project_pipeline_path(project, pipeline) - Gitlab::Routing.url_helpers.namespace_project_pipeline_path( - project.namespace, - project, - pipeline, - format: :json) + Gitlab::Routing.url_helpers.project_pipeline_path(project, pipeline, format: :json) end def project_job_path(project, job) - Gitlab::Routing.url_helpers.namespace_project_build_path( - project.namespace, - project, - job.id, - format: :json) + Gitlab::Routing.url_helpers.project_build_path(project, job.id, format: :json) end end diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb index 92e622285de..7c02d6cf892 100644 --- a/app/workers/expire_pipeline_cache_worker.rb +++ b/app/workers/expire_pipeline_cache_worker.rb @@ -23,42 +23,24 @@ class ExpirePipelineCacheWorker private def project_pipelines_path(project) - Gitlab::Routing.url_helpers.namespace_project_pipelines_path( - project.namespace, - project, - format: :json) + Gitlab::Routing.url_helpers.project_pipelines_path(project, format: :json) end def project_pipeline_path(project, pipeline) - Gitlab::Routing.url_helpers.namespace_project_pipeline_path( - project.namespace, - project, - pipeline, - format: :json) + Gitlab::Routing.url_helpers.project_pipeline_path(project, pipeline, format: :json) end def commit_pipelines_path(project, commit) - Gitlab::Routing.url_helpers.pipelines_namespace_project_commit_path( - project.namespace, - project, - commit.id, - format: :json) + Gitlab::Routing.url_helpers.pipelines_project_commit_path(project, commit.id, format: :json) end def new_merge_request_pipelines_path(project) - Gitlab::Routing.url_helpers.namespace_project_new_merge_request_path( - project.namespace, - project, - format: :json) + Gitlab::Routing.url_helpers.project_new_merge_request_path(project, format: :json) end def each_pipelines_merge_request_path(project, pipeline) pipeline.all_merge_requests.each do |merge_request| - path = Gitlab::Routing.url_helpers.pipelines_namespace_project_merge_request_path( - project.namespace, - project, - merge_request, - format: :json) + path = Gitlab::Routing.url_helpers.pipelines_project_merge_request_path(project, merge_request, format: :json) yield(path) end |