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. ...@@ -313,6 +313,10 @@ That's all of the required database changes.
::Gitlab::GitAccessCoolWidget ::Gitlab::GitAccessCoolWidget
end end
def self.no_repo_message
git_access_class.error_message(:no_repo)
end
# The feature flag follows the format `geo_#{replicable_name}_replication`, # The feature flag follows the format `geo_#{replicable_name}_replication`,
# so here it would be `geo_cool_widget_replication` # so here it would be `geo_cool_widget_replication`
def self.replication_enabled_by_default? def self.replication_enabled_by_default?
...@@ -351,6 +355,9 @@ That's all of the required database changes. ...@@ -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 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: - [ ] Generate the feature flag definition file by running the feature flag command and following the command prompts:
```shell ```shell
......
...@@ -12,6 +12,10 @@ module Geo ...@@ -12,6 +12,10 @@ module Geo
::Gitlab::GitAccessWiki ::Gitlab::GitAccessWiki
end end
def self.no_repo_message
git_access_class.error_message(:no_group_repo)
end
def repository def repository
model_record.repository model_record.repository
end end
......
...@@ -13,6 +13,10 @@ module Geo ...@@ -13,6 +13,10 @@ module Geo
::Gitlab::GitAccessSnippet ::Gitlab::GitAccessSnippet
end end
def self.no_repo_message
git_access_class.error_message(:no_repo)
end
override :verification_feature_flag_enabled? override :verification_feature_flag_enabled?
def self.verification_feature_flag_enabled? def self.verification_feature_flag_enabled?
true true
......
...@@ -45,9 +45,11 @@ module Geo ...@@ -45,9 +45,11 @@ module Geo
log_info('Expiring caches') log_info('Expiring caches')
repository.after_create repository.after_create
rescue Gitlab::Shell::Error, Gitlab::Git::BaseError => e 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. # In some cases repository does not exist, the only way to know about this
# If it does not exist we should consider it as successfully downloaded. # is to parse the error text. If the repository does not exist on the
if e.message.include?(replicator.class.git_access_class.error_message(:no_repo)) # 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') log_info('Repository is not found, marking it as successfully synced')
mark_sync_as_successful(missing_on_primary: true) mark_sync_as_successful(missing_on_primary: true)
else else
......
...@@ -6,4 +6,10 @@ RSpec.describe Geo::GroupWikiRepositoryReplicator do ...@@ -6,4 +6,10 @@ RSpec.describe Geo::GroupWikiRepositoryReplicator do
let(:model_record) { build(:group_wiki_repository, group: create(:group)) } let(:model_record) { build(:group_wiki_repository, group: create(:group)) }
include_examples 'a repository replicator' 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 end
...@@ -8,4 +8,10 @@ RSpec.describe Geo::SnippetRepositoryReplicator do ...@@ -8,4 +8,10 @@ RSpec.describe Geo::SnippetRepositoryReplicator do
include_examples 'a repository replicator' include_examples 'a repository replicator'
it_behaves_like 'a verifiable 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 end
...@@ -120,6 +120,8 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -120,6 +120,8 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
.with(url_to_repo, forced: true, http_authorization_header: anything) .with(url_to_repo, forced: true, http_authorization_header: anything)
.and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessSnippet::ERROR_MESSAGES[:no_repo])) .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 subject.execute
expect(registry).to have_attributes( expect(registry).to have_attributes(
......
...@@ -128,6 +128,12 @@ RSpec.shared_examples 'a repository replicator' do ...@@ -128,6 +128,12 @@ RSpec.shared_examples 'a repository replicator' do
end end
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 describe '#model' do
let(:invoke_model) { replicator.class.model } 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