Commit 048eaa02 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch '204856-replicating-objects-in-object-storage-schedules-removal-and-re-syncs' into 'master'

Fix: [Geo]Replicating objects in object storage schedules removal

Closes #204856

See merge request gitlab-org/gitlab!24901
parents e8d50ea9 33e38761
---
title: 'Geo: Don''t clean up files in object storage when Geo is responsible of syncing
them'
merge_request: 24901
author:
type: fixed
...@@ -7,10 +7,10 @@ module Geo ...@@ -7,10 +7,10 @@ module Geo
MAX_CAPACITY = 1000 MAX_CAPACITY = 1000
def perform def perform
# No need to run when objects stored in Object Storage should be synced too
return if sync_object_storage_enabled?
# No need to run when nothing is configured to be in Object Storage # No need to run when nothing is configured to be in Object Storage
return unless attachments_object_store_enabled? || return unless object_store_enabled?
lfs_objects_object_store_enabled? ||
job_artifacts_object_store_enabled?
super super
end end
...@@ -93,6 +93,16 @@ module Geo ...@@ -93,6 +93,16 @@ module Geo
JobArtifactUploader.object_store_enabled? JobArtifactUploader.object_store_enabled?
end end
def object_store_enabled?
attachments_object_store_enabled? ||
lfs_objects_object_store_enabled? ||
job_artifacts_object_store_enabled?
end
def sync_object_storage_enabled?
current_node.sync_object_storage
end
def attachments_finder def attachments_finder
@attachments_finder ||= AttachmentRegistryFinder.new(current_node_id: current_node.id) @attachments_finder ||= AttachmentRegistryFinder.new(current_node_id: current_node.id)
end end
......
...@@ -7,7 +7,7 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo, :geo_fdw do ...@@ -7,7 +7,7 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo, :geo_fdw do
include ExclusiveLeaseHelpers include ExclusiveLeaseHelpers
let(:primary) { create(:geo_node, :primary, host: 'primary-geo-node') } let(:primary) { create(:geo_node, :primary, host: 'primary-geo-node') }
let(:secondary) { create(:geo_node) } let(:secondary) { create(:geo_node, :local_storage_only) }
before do before do
stub_current_geo_node(secondary) stub_current_geo_node(secondary)
...@@ -22,6 +22,14 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo, :geo_fdw do ...@@ -22,6 +22,14 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo, :geo_fdw do
subject.perform subject.perform
end end
it 'does not run when sync_object_storage is enabled' do
secondary.update_column(:sync_object_storage, true)
expect(subject).not_to receive(:try_obtain_lease)
subject.perform
end
context 'with LFS objects' do context 'with LFS objects' do
let(:lfs_object_local) { create(:lfs_object) } let(:lfs_object_local) { create(:lfs_object) }
let(:lfs_object_remote) { create(:lfs_object, :object_storage) } let(:lfs_object_remote) { create(:lfs_object, :object_storage) }
......
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