Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-29 15:08:23 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-29 15:08:23 +0300
commitd1d4dfb74a55a1b56b9451b2a844c57e05c9557f (patch)
tree4481753bb0311b55d1ff4193809a5bed847357d3 /lib
parent4011c903cf82eb37720b1b9526db595801cdff4f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/admin/batched_background_migrations.rb42
-rw-r--r--lib/api/api.rb2
-rw-r--r--lib/api/entities/batched_background_migration.rb12
-rw-r--r--lib/gitlab/ci/config.rb24
-rw-r--r--lib/gitlab/ci/config/entry/root.rb18
-rw-r--r--lib/gitlab/x509/signature.rb8
6 files changed, 76 insertions, 30 deletions
diff --git a/lib/api/admin/batched_background_migrations.rb b/lib/api/admin/batched_background_migrations.rb
index e8cc08a23be..7e612b5b66a 100644
--- a/lib/api/admin/batched_background_migrations.rb
+++ b/lib/api/admin/batched_background_migrations.rb
@@ -12,7 +12,15 @@ module API
namespace 'admin' do
resources 'batched_background_migrations/:id' do
- desc 'Retrieve a batched background migration'
+ desc 'Retrieve a batched background migration' do
+ success ::API::Entities::BatchedBackgroundMigration
+ failure [
+ { code: 401, message: '401 Unauthorized' },
+ { code: 403, message: '403 Forbidden' },
+ { code: 404, message: '404 Not found' }
+ ]
+ tags %w[batched_background_migrations]
+ end
params do
optional :database,
type: String,
@@ -31,7 +39,15 @@ module API
end
resources 'batched_background_migrations' do
- desc 'Get the list of the batched background migrations'
+ desc 'Get the list of batched background migrations' do
+ success ::API::Entities::BatchedBackgroundMigration
+ failure [
+ { code: 401, message: '401 Unauthorized' },
+ { code: 403, message: '403 Forbidden' }
+ ]
+ is_array true
+ tags %w[batched_background_migrations]
+ end
params do
optional :database,
type: String,
@@ -48,7 +64,16 @@ module API
end
resources 'batched_background_migrations/:id/resume' do
- desc 'Resume a batched background migration'
+ desc 'Resume a batched background migration' do
+ success ::API::Entities::BatchedBackgroundMigration
+ failure [
+ { code: 401, message: '401 Unauthorized' },
+ { code: 403, message: '403 Forbidden' },
+ { code: 404, message: '404 Not found' },
+ { code: 422, message: 'You can resume only `paused` batched background migrations.' }
+ ]
+ tags %w[batched_background_migrations]
+ end
params do
optional :database,
type: String,
@@ -73,7 +98,16 @@ module API
end
resources 'batched_background_migrations/:id/pause' do
- desc 'Pause a batched background migration'
+ desc 'Pause a batched background migration' do
+ success ::API::Entities::BatchedBackgroundMigration
+ failure [
+ { code: 401, message: '401 Unauthorized' },
+ { code: 403, message: '403 Forbidden' },
+ { code: 404, message: '404 Not found' },
+ { code: 422, message: 'You can pause only `active` batched background migrations.' }
+ ]
+ tags %w[batched_background_migrations]
+ end
params do
optional :database,
type: String,
diff --git a/lib/api/api.rb b/lib/api/api.rb
index f5a6482adbb..d110044f30c 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -171,6 +171,7 @@ module API
namespace do
# Keep in alphabetical order
mount ::API::AccessRequests
+ mount ::API::Admin::BatchedBackgroundMigrations
mount ::API::Admin::Ci::Variables
mount ::API::Admin::InstanceClusters
mount ::API::Admin::PlanLimits
@@ -283,7 +284,6 @@ module API
end
# Keep in alphabetical order
- mount ::API::Admin::BatchedBackgroundMigrations
mount ::API::Admin::Sidekiq
mount ::API::AwardEmoji
mount ::API::Boards
diff --git a/lib/api/entities/batched_background_migration.rb b/lib/api/entities/batched_background_migration.rb
index eba17ff98f4..08e4681e0aa 100644
--- a/lib/api/entities/batched_background_migration.rb
+++ b/lib/api/entities/batched_background_migration.rb
@@ -3,12 +3,12 @@
module API
module Entities
class BatchedBackgroundMigration < Grape::Entity
- expose :id
- expose :job_class_name
- expose :table_name
- expose :status, &:status_name
- expose :progress
- expose :created_at
+ expose :id, documentation: { type: :string, example: "1234" }
+ expose :job_class_name, documentation: { type: :string, example: "CopyColumnUsingBackgroundMigrationJob" }
+ expose :table_name, documentation: { type: :string, example: "events" }
+ expose :status_name, as: :status, override: true, documentation: { type: :string, example: "active" }
+ expose :progress, documentation: { type: :float, example: 50 }
+ expose :created_at, documentation: { type: :dateTime, example: "2022-11-28T16:26:39+02:00" }
end
end
end
diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb
index ee537f4efe5..51dc7f33cc1 100644
--- a/lib/gitlab/ci/config.rb
+++ b/lib/gitlab/ci/config.rb
@@ -26,7 +26,7 @@ module Gitlab
@source_ref_path = pipeline&.source_ref_path
@project = project
- @context = self.logger.instrument(:config_build_context) do
+ @context = self.logger.instrument(:config_build_context, once: true) do
pipeline ||= ::Ci::Pipeline.new(project: project, sha: sha, user: user, source: source)
build_context(project: project, pipeline: pipeline, sha: sha, user: user, parent_pipeline: parent_pipeline)
end
@@ -35,12 +35,16 @@ module Gitlab
@source = source
- @config = self.logger.instrument(:config_expand) do
+ @config = self.logger.instrument(:config_expand, once: true) do
expand_config(config)
end
- @root = self.logger.instrument(:config_compose) do
- Entry::Root.new(@config, project: project, user: user).tap(&:compose!)
+ @root = self.logger.instrument(:config_root, once: true) do
+ Entry::Root.new(@config, project: project, user: user, logger: self.logger)
+ end
+
+ self.logger.instrument(:config_root_compose, once: true) do
+ @root.compose!
end
rescue *rescue_errors => e
raise Config::ConfigError, e.message
@@ -123,23 +127,23 @@ module Gitlab
end
def build_config(config)
- initial_config = logger.instrument(:config_yaml_load) do
+ initial_config = logger.instrument(:config_yaml_load, once: true) do
Config::Yaml.load!(config)
end
- initial_config = logger.instrument(:config_external_process) do
+ initial_config = logger.instrument(:config_external_process, once: true) do
Config::External::Processor.new(initial_config, @context).perform
end
- initial_config = logger.instrument(:config_yaml_extend) do
+ initial_config = logger.instrument(:config_yaml_extend, once: true) do
Config::Extendable.new(initial_config).to_hash
end
- initial_config = logger.instrument(:config_tags_resolve) do
+ initial_config = logger.instrument(:config_tags_resolve, once: true) do
Config::Yaml::Tags::Resolver.new(initial_config).to_hash
end
- logger.instrument(:config_stages_inject) do
+ logger.instrument(:config_stages_inject, once: true) do
Config::EdgeStagesInjector.new(initial_config).to_hash
end
end
@@ -163,7 +167,7 @@ module Gitlab
end
def build_variables(pipeline:)
- logger.instrument(:config_build_variables) do
+ logger.instrument(:config_build_variables, once: true) do
pipeline
.variables_builder
.config_variables
diff --git a/lib/gitlab/ci/config/entry/root.rb b/lib/gitlab/ci/config/entry/root.rb
index a30e6a0d9c3..1e6dbb22209 100644
--- a/lib/gitlab/ci/config/entry/root.rb
+++ b/lib/gitlab/ci/config/entry/root.rb
@@ -103,12 +103,16 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def compose_jobs!
- factory = ::Gitlab::Config::Entry::Factory.new(Entry::Jobs)
- .value(jobs_config)
- .with(key: :jobs, parent: self,
- description: 'Jobs definition for this pipeline')
+ factory = logger.instrument(:config_root_compose_jobs_factory, once: true) do
+ ::Gitlab::Config::Entry::Factory.new(Entry::Jobs)
+ .value(jobs_config)
+ .with(key: :jobs, parent: self,
+ description: 'Jobs definition for this pipeline')
+ end
- @entries[:jobs] = factory.create!
+ @entries[:jobs] = logger.instrument(:config_root_compose_jobs_create, once: true) do
+ factory.create!
+ end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -123,6 +127,10 @@ module Gitlab
@config = @config.except(*@jobs_config.keys)
end
+
+ def logger
+ metadata[:logger]
+ end
end
end
end
diff --git a/lib/gitlab/x509/signature.rb b/lib/gitlab/x509/signature.rb
index 3b941853ebd..6eaa623fab6 100644
--- a/lib/gitlab/x509/signature.rb
+++ b/lib/gitlab/x509/signature.rb
@@ -27,8 +27,8 @@ module Gitlab
X509Certificate.safe_create!(certificate_attributes) unless verified_signature.nil?
end
- def user
- strong_memoize(:user) { User.find_by_any_email(@email) }
+ def signed_by_user
+ strong_memoize(:signed_by_user) { User.find_by_any_email(@email) }
end
def verified_signature
@@ -40,9 +40,9 @@ module Gitlab
x509_certificate.nil? ||
x509_certificate.revoked? ||
!verified_signature ||
- user.nil?
+ signed_by_user.nil?
- if user.verified_emails.include?(@email.downcase) && certificate_email.casecmp?(@email)
+ if signed_by_user.verified_emails.include?(@email.downcase) && certificate_email.casecmp?(@email)
:verified
else
:unverified