diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /lib/gitlab/import_export | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'lib/gitlab/import_export')
4 files changed, 18 insertions, 19 deletions
diff --git a/lib/gitlab/import_export/json/streaming_serializer.rb b/lib/gitlab/import_export/json/streaming_serializer.rb index 20f9c668b9c..05b7679e0ff 100644 --- a/lib/gitlab/import_export/json/streaming_serializer.rb +++ b/lib/gitlab/import_export/json/streaming_serializer.rb @@ -7,7 +7,7 @@ module Gitlab include Gitlab::ImportExport::CommandLineUtil BATCH_SIZE = 100 - SMALLER_BATCH_SIZE = 20 + SMALLER_BATCH_SIZE = 2 def self.batch_size(exportable) if Feature.enabled?(:export_reduce_relation_batch_size, exportable) @@ -69,8 +69,16 @@ module Gitlab key_preloads = preloads&.dig(key) records = records.preload(key_preloads) if key_preloads - records.find_each(batch_size: batch_size) do |record| - items << Raw.new(record.to_json(options)) + records.in_batches(of: batch_size) do |batch| # rubocop:disable Cop/InBatches + # order each batch by its primary key to ensure + # consistent and predictable ordering of each exported relation + # as additional `WHERE` clauses can impact the order in which data is being + # returned by database when no `ORDER` is specified + batch = batch.reorder(batch.klass.primary_key) + + batch.each do |record| + items << Raw.new(record.to_json(options)) + end end end diff --git a/lib/gitlab/import_export/project/import_export.yml b/lib/gitlab/import_export/project/import_export.yml index f0b733d7e95..aa961bd8d19 100644 --- a/lib/gitlab/import_export/project/import_export.yml +++ b/lib/gitlab/import_export/project/import_export.yml @@ -89,7 +89,6 @@ tree: - :triggers - :pipeline_schedules - :container_expiration_policy - - :services - protected_branches: - :merge_access_levels - :push_access_levels @@ -169,6 +168,7 @@ excluded_attributes: - :marked_for_deletion_by_user_id - :compliance_framework_setting - :show_default_award_emojis + - :services namespaces: - :runners_token - :runners_token_encrypted @@ -261,10 +261,6 @@ excluded_attributes: runners: - :token - :token_encrypted - services: - - :inherit_from_id - - :instance - - :template error_tracking_setting: - :encrypted_token - :encrypted_token_iv @@ -313,12 +309,14 @@ excluded_attributes: - :merge_request_id - :external_pull_request_id - :ci_ref_id + - :locked stages: - :pipeline_id merge_access_levels: - :protected_branch_id push_access_levels: - :protected_branch_id + - :deploy_key_id unprotect_access_levels: - :protected_branch_id create_access_levels: @@ -353,8 +351,6 @@ methods: - :type statuses: - :type - services: - - :type merge_request_diff_files: - :utf8_diff merge_requests: diff --git a/lib/gitlab/import_export/project/relation_factory.rb b/lib/gitlab/import_export/project/relation_factory.rb index 3ab9f2c4bfa..ae92228276e 100644 --- a/lib/gitlab/import_export/project/relation_factory.rb +++ b/lib/gitlab/import_export/project/relation_factory.rb @@ -70,10 +70,8 @@ module Gitlab private def invalid_relation? - # Do not create relation if it is: - # - An unknown service - # - A legacy trigger - unknown_service? || legacy_trigger? + # Do not create relation if it is a legacy trigger + legacy_trigger? end def setup_models @@ -137,11 +135,6 @@ module Gitlab end end - def unknown_service? - @relation_name == :services && parsed_relation_hash['type'] && - !Object.const_defined?(parsed_relation_hash['type']) - end - def legacy_trigger? @relation_name == :'Ci::Trigger' && @relation_hash['owner_id'].nil? end diff --git a/lib/gitlab/import_export/snippet_repo_restorer.rb b/lib/gitlab/import_export/snippet_repo_restorer.rb index 31b1a37bbe1..2d0aa05fc3c 100644 --- a/lib/gitlab/import_export/snippet_repo_restorer.rb +++ b/lib/gitlab/import_export/snippet_repo_restorer.rb @@ -42,6 +42,8 @@ module Gitlab snippet.repository.expire_exists_cache raise SnippetRepositoryError, _("Invalid repository bundle for snippet with id %{snippet_id}") % { snippet_id: snippet.id } + else + Snippets::UpdateStatisticsService.new(snippet).execute end end |