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
This commit is contained in:
commit
f6a60663ce
|
@ -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 @@ def self.git_access_class
|
|||
::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 @@ def self.git_access_class
|
|||
::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 @@ def sync_repository
|
|||
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 @@
|
|||
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 @@
|
|||
|
||||
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 @@
|
|||
.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 @@
|
|||
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 }
|
||||
|
||||
|
|
Loading…
Reference in a new issue