Commit be068a3c authored by Michael Kozono's avatar Michael Kozono

Merge branch '289841-follow-up-from-geo-backfill-existing-snippets' into 'master'

Make generic Destroy Worker for SSF

See merge request gitlab-org/gitlab!48803
parents eb411321 0198c2e4
...@@ -48,12 +48,6 @@ module Geo ...@@ -48,12 +48,6 @@ module Geo
carrierwave_uploader.path carrierwave_uploader.path
end end
private
def download
::Geo::BlobDownloadService.new(replicator: self).execute
end
def replicate_destroy(event_data) def replicate_destroy(event_data)
::Geo::FileRegistryRemovalService.new( ::Geo::FileRegistryRemovalService.new(
replicable_name, replicable_name,
...@@ -62,6 +56,12 @@ module Geo ...@@ -62,6 +56,12 @@ module Geo
).execute ).execute
end end
private
def download
::Geo::BlobDownloadService.new(replicator: self).execute
end
def deleted_params def deleted_params
{ model_record_id: model_record.id, blob_path: blob_path } { model_record_id: model_record.id, blob_path: blob_path }
end end
......
...@@ -42,7 +42,7 @@ class Geo::BaseRegistry < Geo::TrackingBase ...@@ -42,7 +42,7 @@ class Geo::BaseRegistry < Geo::TrackingBase
end end
def self.delete_worker_class def self.delete_worker_class
::Geo::FileRegistryRemovalWorker ::Geo::DestroyWorker
end end
def self.replicator_class def self.replicator_class
......
...@@ -27,4 +27,8 @@ class Geo::JobArtifactRegistry < Geo::BaseRegistry ...@@ -27,4 +27,8 @@ class Geo::JobArtifactRegistry < Geo::BaseRegistry
delete_worker_class.perform_async(:job_artifact, artifact_id) delete_worker_class.perform_async(:job_artifact, artifact_id)
end end
end end
def self.delete_worker_class
::Geo::FileRegistryRemovalWorker
end
end end
...@@ -22,4 +22,8 @@ class Geo::LfsObjectRegistry < Geo::BaseRegistry ...@@ -22,4 +22,8 @@ class Geo::LfsObjectRegistry < Geo::BaseRegistry
delete_worker_class.perform_async(:lfs, lfs_object_id) delete_worker_class.perform_async(:lfs, lfs_object_id)
end end
end end
def self.delete_worker_class
::Geo::FileRegistryRemovalWorker
end
end end
...@@ -7,8 +7,4 @@ class Geo::SnippetRepositoryRegistry < Geo::BaseRegistry ...@@ -7,8 +7,4 @@ class Geo::SnippetRepositoryRegistry < Geo::BaseRegistry
MODEL_FOREIGN_KEY = :snippet_repository_id MODEL_FOREIGN_KEY = :snippet_repository_id
belongs_to :snippet_repository, class_name: 'SnippetRepository' belongs_to :snippet_repository, class_name: 'SnippetRepository'
def self.delete_worker_class
::Geo::FrameworkRepositoryDestroyWorker
end
end end
...@@ -68,6 +68,10 @@ class Geo::UploadRegistry < Geo::BaseRegistry ...@@ -68,6 +68,10 @@ class Geo::UploadRegistry < Geo::BaseRegistry
end end
end end
def self.delete_worker_class
::Geo::FileRegistryRemovalWorker
end
def self.with_search(query) def self.with_search(query)
return all if query.nil? return all if query.nil?
......
...@@ -355,15 +355,15 @@ ...@@ -355,15 +355,15 @@
:weight: 1 :weight: 1
:idempotent: :idempotent:
:tags: [] :tags: []
- :name: geo:geo_event - :name: geo:geo_destroy
:feature_category: :geo_replication :feature_category: :geo_replication
:has_external_dependencies: :has_external_dependencies:
:urgency: :low :urgency: :low
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 1 :weight: 1
:idempotent: :idempotent: true
:tags: [] :tags: []
- :name: geo:geo_file_download - :name: geo:geo_event
:feature_category: :geo_replication :feature_category: :geo_replication
:has_external_dependencies: :has_external_dependencies:
:urgency: :low :urgency: :low
...@@ -371,7 +371,7 @@ ...@@ -371,7 +371,7 @@
:weight: 1 :weight: 1
:idempotent: :idempotent:
:tags: [] :tags: []
- :name: geo:geo_file_registry_removal - :name: geo:geo_file_download
:feature_category: :geo_replication :feature_category: :geo_replication
:has_external_dependencies: :has_external_dependencies:
:urgency: :low :urgency: :low
...@@ -379,7 +379,7 @@ ...@@ -379,7 +379,7 @@
:weight: 1 :weight: 1
:idempotent: :idempotent:
:tags: [] :tags: []
- :name: geo:geo_file_removal - :name: geo:geo_file_registry_removal
:feature_category: :geo_replication :feature_category: :geo_replication
:has_external_dependencies: :has_external_dependencies:
:urgency: :low :urgency: :low
...@@ -387,13 +387,13 @@ ...@@ -387,13 +387,13 @@
:weight: 1 :weight: 1
:idempotent: :idempotent:
:tags: [] :tags: []
- :name: geo:geo_framework_repository_destroy - :name: geo:geo_file_removal
:feature_category: :geo_replication :feature_category: :geo_replication
:has_external_dependencies: :has_external_dependencies:
:urgency: :low :urgency: :low
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 1 :weight: 1
:idempotent: true :idempotent:
:tags: [] :tags: []
- :name: geo:geo_hashed_storage_attachments_migration - :name: geo:geo_hashed_storage_attachments_migration
:feature_category: :geo_replication :feature_category: :geo_replication
......
# frozen_string_literal: true # frozen_string_literal: true
module Geo module Geo
class FrameworkRepositoryDestroyWorker class DestroyWorker
include ApplicationWorker include ApplicationWorker
include GeoQueue include GeoQueue
include ::Gitlab::Geo::LogHelpers include ::Gitlab::Geo::LogHelpers
...@@ -11,11 +11,11 @@ module Geo ...@@ -11,11 +11,11 @@ module Geo
loggable_arguments 0 loggable_arguments 0
def perform(replicable_name, replicable_id) def perform(replicable_name, replicable_id)
log_info('Executing Geo::FrameworkRepositoryDestroyWorker', replicable_id: replicable_id, replicable_name: replicable_name) log_info('Executing Geo::DestroyWorker', replicable_id: replicable_id, replicable_name: replicable_name)
replicator = Gitlab::Geo::Replicator.for_replicable_params(replicable_name: replicable_name, replicable_id: replicable_id) replicator = ::Gitlab::Geo::Replicator.for_replicable_params(replicable_name: replicable_name, replicable_id: replicable_id)
::Geo::RepositoryRegistryRemovalService.new(replicator).execute replicator.replicate_destroy({})
end end
end end
end end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::DestroyWorker, :geo do
let(:replicator) { double(:replicator) }
describe '#perform' do
it 'calls replicator#replicate_destroy' do
expect(replicator).to receive(:replicate_destroy)
expect(Gitlab::Geo::Replicator).to receive(:for_replicable_params).with(replicable_name: 'snippet_repository', replicable_id: 1).and_return(replicator)
described_class.new.perform('snippet_repository', 1)
end
end
include_examples 'an idempotent worker' do
let(:job_args) { ['snippet_repository', 1] }
it 'calls replicator#replicate_destroy' do
allow(Gitlab::Geo::Replicator).to receive(:for_replicable_params).and_return(replicator)
expect(replicator).to receive(:replicate_destroy).exactly(IdempotentWorkerHelper::WORKER_EXEC_TIMES).times
subject
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