Commit f7fd7b03 authored by Catalin Irimie's avatar Catalin Irimie

Fix object deduplication on Geo first sync

For forks of large projects, if the project does not exist
when the first sync happens, or the sync fails for any reason,
we did not trigger object deduplicationg.

Changelog: fixed
EE: true
parent 2fdce865
......@@ -79,8 +79,11 @@ module Geo
fetch_geo_mirror(repository)
else
ensure_repository
fetch_geo_mirror(repository)
# Because we ensure a repository exists by this point, we need to
# mark it as new, even if fetching the mirror fails, we should run
# housekeeping to enable object deduplication to run
@new_repository = true
fetch_geo_mirror(repository)
end
update_root_ref
......
......@@ -60,8 +60,11 @@ module Geo
fetch_geo_mirror(repository)
else
ensure_repository
fetch_geo_mirror(repository)
# Because we ensure a repository exists by this point, we need to
# mark it as new, even if fetching the mirror fails, we should run
# housekeeping to enable object deduplication to run
@new_repository = true
fetch_geo_mirror(repository)
end
update_root_ref
......
......@@ -428,6 +428,13 @@ RSpec.describe Geo::RepositorySyncService, :geo do
subject.execute
end
it "indicates the repository is not new even with errors" do
allow(subject).to receive(:redownload_repository).and_raise(Gitlab::Shell::Error)
expect(Geo::ProjectHousekeepingService).to receive(:new).with(project, new_repository: false).and_call_original
subject.execute
end
end
context 'when repository did not exist' do
......@@ -441,6 +448,13 @@ RSpec.describe Geo::RepositorySyncService, :geo do
subject.execute
end
it "indicates the repository is new when there were errors" do
allow(subject).to receive(:fetch_geo_mirror).and_raise(Gitlab::Shell::Error)
expect(Geo::ProjectHousekeepingService).to receive(:new).with(project, new_repository: true).and_call_original
subject.execute
end
end
context 'when repository already existed' do
......@@ -449,5 +463,12 @@ RSpec.describe Geo::RepositorySyncService, :geo do
subject.execute
end
it "indicates the repository is not new even with errors" do
allow(subject).to receive(:fetch_geo_mirror).and_raise(Gitlab::Shell::Error)
expect(Geo::ProjectHousekeepingService).to receive(:new).with(project, new_repository: false).and_call_original
subject.execute
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