Commit f6a60663 authored by Michael Kozono's avatar Michael Kozono

Merge branch...

Merge branch '345332-geo-group-wiki-repositories-that-do-not-exist-on-the-primary-are-not-marked-as-synced' into 'master'

Geo - Fix no repo error message for group-level wikis

See merge request gitlab-org/gitlab!74133
parents b1246cf6 f3a0725f
......@@ -313,6 +313,10 @@ That's all of the required database changes.
::Gitlab::GitAccessCoolWidget
end
def self.no_repo_message
git_access_class.error_message(:no_repo)
end
# The feature flag follows the format `geo_#{replicable_name}_replication`,
# so here it would be `geo_cool_widget_replication`
def self.replication_enabled_by_default?
......@@ -351,6 +355,9 @@ That's all of the required database changes.
```
- [ ] Make sure a Geo secondary site can request and download Cool Widgets on the Geo primary site. You may need to make some changes to `Gitlab::GitAccessCoolWidget`. For example, see [this change for Group-level Wikis](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54914/diffs?commit_id=0f2b36f66697b4addbc69bd377ee2818f648dd33).
- [ ] Make sure a Geo secondary site can replicate Cool Widgets where repository does not exist on the Geo primary site. The only way to know about this is to parse the error text. You may need to make some changes to `Gitlab::CoolWidgetReplicator.no_repo_message` to return the proper error message. For example, see [this change for Group-level Wikis](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74133).
- [ ] Generate the feature flag definition file by running the feature flag command and following the command prompts:
```shell
......
......@@ -12,6 +12,10 @@ module Geo
::Gitlab::GitAccessWiki
end
def self.no_repo_message
git_access_class.error_message(:no_group_repo)
end
def repository
model_record.repository
end
......
......@@ -13,6 +13,10 @@ module Geo
::Gitlab::GitAccessSnippet
end
def self.no_repo_message
git_access_class.error_message(:no_repo)
end
override :verification_feature_flag_enabled?
def self.verification_feature_flag_enabled?
true
......
......@@ -45,9 +45,11 @@ module Geo
log_info('Expiring caches')
repository.after_create
rescue Gitlab::Shell::Error, Gitlab::Git::BaseError => e
# In some cases repository does not exist, the only way to know about this is to parse the error text.
# If it does not exist we should consider it as successfully downloaded.
if e.message.include?(replicator.class.git_access_class.error_message(:no_repo))
# In some cases repository does not exist, the only way to know about this
# is to parse the error text. If the repository does not exist on the
# primary, then the state on this secondary matches the primary, and
# therefore the repository is successfully synced.
if e.message.include?(replicator.class.no_repo_message)
log_info('Repository is not found, marking it as successfully synced')
mark_sync_as_successful(missing_on_primary: true)
else
......
......@@ -6,4 +6,10 @@ RSpec.describe Geo::GroupWikiRepositoryReplicator do
let(:model_record) { build(:group_wiki_repository, group: create(:group)) }
include_examples 'a repository replicator'
describe '.no_repo_message' do
it 'returns the proper error message for group-level wikis' do
expect(replicator.class.no_repo_message).to eq(::Gitlab::GitAccessWiki.error_message(:no_group_repo))
end
end
end
......@@ -8,4 +8,10 @@ RSpec.describe Geo::SnippetRepositoryReplicator do
include_examples 'a repository replicator'
it_behaves_like 'a verifiable replicator'
describe '.no_repo_message' do
it 'returns the proper error message for snippet repositories' do
expect(replicator.class.no_repo_message).to eq(::Gitlab::GitAccessSnippet.error_message(:no_repo))
end
end
end
......@@ -120,6 +120,8 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
.with(url_to_repo, forced: true, http_authorization_header: anything)
.and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessSnippet::ERROR_MESSAGES[:no_repo]))
expect(replicator.class).to receive(:no_repo_message).once.and_call_original
subject.execute
expect(registry).to have_attributes(
......
......@@ -128,6 +128,12 @@ RSpec.shared_examples 'a repository replicator' do
end
end
describe '.no_repo_message' do
it 'is implemented' do
expect(replicator.class.no_repo_message).to be_a(String)
end
end
describe '#model' do
let(:invoke_model) { replicator.class.model }
......
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