summaryrefslogtreecommitdiff
path: root/lib/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/ci/config/entry/cache.rb11
-rw-r--r--lib/gitlab/ci/pipeline/seed/build/cache.rb4
-rw-r--r--lib/gitlab/config_checker/external_database_checker.rb6
-rw-r--r--lib/gitlab/database.rb5
-rw-r--r--lib/gitlab/database/partitioning.rb2
-rw-r--r--lib/gitlab/github_import/client.rb4
-rw-r--r--lib/gitlab/github_import/importer/collaborators_importer.rb19
-rw-r--r--lib/gitlab/github_import/settings.rb12
-rw-r--r--lib/gitlab/metrics/subscribers/rails_cache.rb3
9 files changed, 56 insertions, 10 deletions
diff --git a/lib/gitlab/ci/config/entry/cache.rb b/lib/gitlab/ci/config/entry/cache.rb
index a635f409109..b3ff74c14da 100644
--- a/lib/gitlab/ci/config/entry/cache.rb
+++ b/lib/gitlab/ci/config/entry/cache.rb
@@ -9,11 +9,12 @@ module Gitlab
include ::Gitlab::Config::Entry::Validatable
include ::Gitlab::Config::Entry::Attributable
- ALLOWED_KEYS = %i[key untracked paths when policy unprotect].freeze
+ ALLOWED_KEYS = %i[key untracked paths when policy unprotect fallback_keys].freeze
ALLOWED_POLICY = %w[pull-push push pull].freeze
DEFAULT_POLICY = 'pull-push'
ALLOWED_WHEN = %w[on_success on_failure always].freeze
DEFAULT_WHEN = 'on_success'
+ DEFAULT_FALLBACK_KEYS = [].freeze
validations do
validates :config, type: Hash, allowed_keys: ALLOWED_KEYS
@@ -27,6 +28,8 @@ module Gitlab
in: ALLOWED_WHEN,
message: "should be one of: #{ALLOWED_WHEN.join(', ')}"
}
+
+ validates :fallback_keys, length: { maximum: 5, too_long: "has to many entries (maximum %{count})" }
end
end
@@ -42,7 +45,10 @@ module Gitlab
entry :paths, Entry::Paths,
description: 'Specify which paths should be cached across builds.'
- attributes :policy, :when, :unprotect
+ entry :fallback_keys, ::Gitlab::Config::Entry::ArrayOfStrings,
+ description: 'List of keys to download cache from if no cache hit occurred for key'
+
+ attributes :policy, :when, :unprotect, :fallback_keys
def value
result = super
@@ -52,6 +58,7 @@ module Gitlab
result[:policy] = policy || DEFAULT_POLICY
# Use self.when to avoid conflict with reserved word
result[:when] = self.when || DEFAULT_WHEN
+ result[:fallback_keys] = fallback_keys || DEFAULT_FALLBACK_KEYS
result
end
diff --git a/lib/gitlab/ci/pipeline/seed/build/cache.rb b/lib/gitlab/ci/pipeline/seed/build/cache.rb
index 409b6658cc0..936344b9ae8 100644
--- a/lib/gitlab/ci/pipeline/seed/build/cache.rb
+++ b/lib/gitlab/ci/pipeline/seed/build/cache.rb
@@ -16,6 +16,7 @@ module Gitlab
@when = local_cache.delete(:when)
@unprotect = local_cache.delete(:unprotect)
@custom_key_prefix = custom_key_prefix
+ @fallback_keys = local_cache.delete(:fallback_keys)
raise ArgumentError, "unknown cache keys: #{local_cache.keys}" if local_cache.any?
end
@@ -27,7 +28,8 @@ module Gitlab
policy: @policy,
untracked: @untracked,
when: @when,
- unprotect: @unprotect
+ unprotect: @unprotect,
+ fallback_keys: @fallback_keys
}.compact
end
diff --git a/lib/gitlab/config_checker/external_database_checker.rb b/lib/gitlab/config_checker/external_database_checker.rb
index ff20833b5be..c95e19940c3 100644
--- a/lib/gitlab/config_checker/external_database_checker.rb
+++ b/lib/gitlab/config_checker/external_database_checker.rb
@@ -21,9 +21,9 @@ module Gitlab
{
type: 'warning',
message: _('Database \'%{database_name}\' is using PostgreSQL %{pg_version_current}, ' \
- 'but PostgreSQL %{pg_version_minimum} is required for this version of GitLab. ' \
- 'Please upgrade your environment to a supported PostgreSQL version, ' \
- 'see %{pg_requirements_url} for details.') % \
+ 'but this version of GitLab requires PostgreSQL %{pg_version_minimum}. ' \
+ 'Please upgrade your environment to a supported PostgreSQL version. ' \
+ 'See %{pg_requirements_url} for details.') % \
{
database_name: database_name,
pg_version_current: database.version,
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index 093667dc624..4197c87f51f 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -193,13 +193,12 @@ module Gitlab
 ███ ███  ██  ██ ██  ██ ██   ████ ██ ██   ████  ██████  
******************************************************************************
- You are using PostgreSQL #{database.version} for the #{name} database, but PostgreSQL >= <%= Gitlab::Database::MINIMUM_POSTGRES_VERSION %>
- is required for this version of GitLab.
+ You are using PostgreSQL #{database.version} for the #{name} database, but this version of GitLab requires PostgreSQL >= <%= Gitlab::Database::MINIMUM_POSTGRES_VERSION %>.
<% if Rails.env.development? || Rails.env.test? %>
If using gitlab-development-kit, please find the relevant steps here:
https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/postgresql.md#upgrade-postgresql
<% end %>
- Please upgrade your environment to a supported PostgreSQL version, see
+ Please upgrade your environment to a supported PostgreSQL version. See
https://docs.gitlab.com/ee/install/requirements.html#database for details.
******************************************************************************
EOS
diff --git a/lib/gitlab/database/partitioning.rb b/lib/gitlab/database/partitioning.rb
index 4a9e002a1a2..7222f148b3f 100644
--- a/lib/gitlab/database/partitioning.rb
+++ b/lib/gitlab/database/partitioning.rb
@@ -27,6 +27,8 @@ module Gitlab
end
def sync_partitions(models_to_sync = registered_for_sync, only_on: nil)
+ return unless Feature.enabled?(:partition_manager_sync_partitions, type: :ops)
+
Gitlab::AppLogger.info(message: 'Syncing dynamic postgres partitions')
Gitlab::Database::EachDatabase.each_model_connection(models_to_sync, only_on: only_on) do |model|
diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb
index 1c9ca9f43a8..886563a6f69 100644
--- a/lib/gitlab/github_import/client.rb
+++ b/lib/gitlab/github_import/client.rb
@@ -112,6 +112,10 @@ module Gitlab
each_object(:branches, *args)
end
+ def collaborators(*args)
+ each_object(:collaborators, *args)
+ end
+
def branch_protection(repo_name, branch_name)
with_rate_limit { octokit.branch_protection(repo_name, branch_name).to_h }
end
diff --git a/lib/gitlab/github_import/importer/collaborators_importer.rb b/lib/gitlab/github_import/importer/collaborators_importer.rb
index dd947632d01..7b18d3dba2a 100644
--- a/lib/gitlab/github_import/importer/collaborators_importer.rb
+++ b/lib/gitlab/github_import/importer/collaborators_importer.rb
@@ -6,6 +6,25 @@ module Gitlab
class CollaboratorsImporter
include ParallelScheduling
+ # The method that will be called for traversing through all the objects to
+ # import, yielding them to the supplied block.
+ def each_object_to_import
+ repo = project.import_source
+
+ direct_collaborators = client.collaborators(repo, affiliation: 'direct')
+ outside_collaborators = client.collaborators(repo, affiliation: 'outside')
+ collaborators_to_import = direct_collaborators.to_a - outside_collaborators.to_a
+
+ collaborators_to_import.each do |collaborator|
+ next if already_imported?(collaborator)
+
+ yield collaborator
+
+ Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched)
+ mark_as_imported(collaborator)
+ end
+ end
+
def importer_class
CollaboratorImporter
end
diff --git a/lib/gitlab/github_import/settings.rb b/lib/gitlab/github_import/settings.rb
index 22ab99df107..0b883de8ed0 100644
--- a/lib/gitlab/github_import/settings.rb
+++ b/lib/gitlab/github_import/settings.rb
@@ -6,6 +6,7 @@ module Gitlab
OPTIONAL_STAGES = {
single_endpoint_issue_events_import: {
label: 'Import issue and pull request events',
+ selected: false,
details: <<-TEXT.split("\n").map(&:strip).join(' ')
For example, opened or closed, renamed, and labeled or unlabeled.
Time required to import these events depends on how many issues or pull requests your project has.
@@ -13,17 +14,27 @@ module Gitlab
},
single_endpoint_notes_import: {
label: 'Use alternative comments import method',
+ selected: false,
details: <<-TEXT.split("\n").map(&:strip).join(' ')
The default method can skip some comments in large projects because of limitations of the GitHub API.
TEXT
},
attachments_import: {
label: 'Import Markdown attachments (links)',
+ selected: false,
details: <<-TEXT.split("\n").map(&:strip).join(' ')
Import Markdown attachments (links) from repository comments, release posts, issue descriptions,
and pull request descriptions. These can include images, text, or binary attachments.
If not imported, links in Markdown to attachments break after you remove the attachments from GitHub.
TEXT
+ },
+ collaborators_import: {
+ label: 'Import collaborators',
+ selected: true,
+ details: <<-TEXT.split("\n").map(&:strip).join(' ')
+ Import direct repository collaborators who are not outside collaborators.
+ Imported collaborators who aren't members of the group you imported the project into consume seats on your GitLab instance.
+ TEXT
}
}.freeze
@@ -32,6 +43,7 @@ module Gitlab
{
name: stage_name.to_s,
label: s_(format("GitHubImport|%{text}", text: data[:label])),
+ selected: data[:selected],
details: s_(format("GitHubImport|%{text}", text: data[:details]))
}
end
diff --git a/lib/gitlab/metrics/subscribers/rails_cache.rb b/lib/gitlab/metrics/subscribers/rails_cache.rb
index 1759c0544b1..b4e9e85a012 100644
--- a/lib/gitlab/metrics/subscribers/rails_cache.rb
+++ b/lib/gitlab/metrics/subscribers/rails_cache.rb
@@ -13,7 +13,8 @@ module Gitlab
return unless current_transaction
- current_transaction.observe(:gitlab_cache_read_multikey_count, event.payload[:key].size) do
+ labels = { store: event.payload[:store].split('::').last }
+ current_transaction.observe(:gitlab_cache_read_multikey_count, event.payload[:key].size, labels) do
buckets [10, 50, 100, 1000]
docstring 'Number of keys for mget in read_multi/fetch_multi'
end