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-10-20 15:10:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-20 15:10:43 +0300
commitbf18f3295b550c564086efd0a32d9a25435ce216 (patch)
tree9ea92eefd45aa38a15152fb28c24d526c1525a5f /lib
parent3f96425b0b9f0b4885b70db01dcd76b311ea87ab (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities/ml/mlflow/run.rb2
-rw-r--r--lib/api/entities/ml/mlflow/run_info.rb2
-rw-r--r--lib/api/entities/ml/mlflow/update_run.rb8
-rw-r--r--lib/api/ml/mlflow.rb16
-rw-r--r--lib/bulk_imports/common/pipelines/entity_finisher.rb8
-rw-r--r--lib/bulk_imports/pipeline/runner.rb39
-rw-r--r--lib/gitlab/diff/file_collection/base.rb4
-rw-r--r--lib/gitlab/kas/client.rb2
8 files changed, 51 insertions, 30 deletions
diff --git a/lib/api/entities/ml/mlflow/run.rb b/lib/api/entities/ml/mlflow/run.rb
index a8e1cfe08dd..8b16c67611f 100644
--- a/lib/api/entities/ml/mlflow/run.rb
+++ b/lib/api/entities/ml/mlflow/run.rb
@@ -6,7 +6,7 @@ module API
module Mlflow
class Run < Grape::Entity
expose :run do
- expose(:info) { |candidate| RunInfo.represent(candidate) }
+ expose :itself, using: RunInfo, as: :info
expose :data do
expose :metrics, using: Metric
expose :params, using: RunParam
diff --git a/lib/api/entities/ml/mlflow/run_info.rb b/lib/api/entities/ml/mlflow/run_info.rb
index 096950e349d..d3934545ba4 100644
--- a/lib/api/entities/ml/mlflow/run_info.rb
+++ b/lib/api/entities/ml/mlflow/run_info.rb
@@ -11,7 +11,7 @@ module API
expose(:start_time) { |candidate| candidate.start_time || 0 }
expose :end_time, expose_nil: false
expose(:status) { |candidate| candidate.status.to_s.upcase }
- expose(:artifact_uri) { |candidate| 'not_implemented' }
+ expose(:artifact_uri) { |candidate, options| "#{options[:packages_url]}#{candidate.artifact_root}" }
expose(:lifecycle_stage) { |candidate| 'active' }
expose(:user_id) { |candidate| candidate.user_id.to_s }
diff --git a/lib/api/entities/ml/mlflow/update_run.rb b/lib/api/entities/ml/mlflow/update_run.rb
index 090d69b8895..55def810ef5 100644
--- a/lib/api/entities/ml/mlflow/update_run.rb
+++ b/lib/api/entities/ml/mlflow/update_run.rb
@@ -5,13 +5,7 @@ module API
module Ml
module Mlflow
class UpdateRun < Grape::Entity
- expose :run_info
-
- private
-
- def run_info
- RunInfo.represent object
- end
+ expose :itself, using: RunInfo, as: :run_info
end
end
end
diff --git a/lib/api/ml/mlflow.rb b/lib/api/ml/mlflow.rb
index 2ffb04ebcbd..f3195e5b6c5 100644
--- a/lib/api/ml/mlflow.rb
+++ b/lib/api/ml/mlflow.rb
@@ -68,6 +68,15 @@ module API
def find_candidate!(iid)
candidate_repository.by_iid(iid) || resource_not_found!
end
+
+ def packages_url
+ path = api_v4_projects_packages_generic_package_version_path(
+ id: user_project.id, package_name: '', file_name: ''
+ )
+ path = path.delete_suffix('/package_version')
+
+ "#{request.base_url}#{path}"
+ end
end
params do
@@ -143,7 +152,8 @@ module API
optional :tags, type: Array, desc: 'This will be ignored'
end
post 'create', urgency: :low do
- present candidate_repository.create!(experiment, params[:start_time]), with: Entities::Ml::Mlflow::Run
+ present candidate_repository.create!(experiment, params[:start_time]),
+ with: Entities::Ml::Mlflow::Run, packages_url: packages_url
end
desc 'Gets an MLFlow Run, which maps to GitLab Candidates' do
@@ -155,7 +165,7 @@ module API
optional :run_uuid, type: String, desc: 'This parameter is ignored'
end
get 'get', urgency: :low do
- present candidate, with: Entities::Ml::Mlflow::Run
+ present candidate, with: Entities::Ml::Mlflow::Run, packages_url: packages_url
end
desc 'Updates a Run.' do
@@ -174,7 +184,7 @@ module API
post 'update', urgency: :low do
candidate_repository.update(candidate, params[:status], params[:end_time])
- present candidate, with: Entities::Ml::Mlflow::UpdateRun
+ present candidate, with: Entities::Ml::Mlflow::UpdateRun, packages_url: packages_url
end
desc 'Logs a metric to a run.' do
diff --git a/lib/bulk_imports/common/pipelines/entity_finisher.rb b/lib/bulk_imports/common/pipelines/entity_finisher.rb
index 5066f622d57..a52504d04bc 100644
--- a/lib/bulk_imports/common/pipelines/entity_finisher.rb
+++ b/lib/bulk_imports/common/pipelines/entity_finisher.rb
@@ -24,11 +24,13 @@ module BulkImports
end
logger.info(
- bulk_import_id: context.bulk_import_id,
- bulk_import_entity_id: context.entity.id,
- bulk_import_entity_type: context.entity.source_type,
+ bulk_import_id: entity.bulk_import_id,
+ bulk_import_entity_id: entity.id,
+ bulk_import_entity_type: entity.source_type,
+ source_full_path: entity.source_full_path,
pipeline_class: self.class.name,
message: "Entity #{entity.status_name}",
+ source_version: entity.bulk_import.source_version_info.to_s,
importer: 'gitlab_migration'
)
diff --git a/lib/bulk_imports/pipeline/runner.rb b/lib/bulk_imports/pipeline/runner.rb
index ef9575d1e96..81f8dee30d9 100644
--- a/lib/bulk_imports/pipeline/runner.rb
+++ b/lib/bulk_imports/pipeline/runner.rb
@@ -99,7 +99,7 @@ module BulkImports
end
def log_import_failure(exception, step)
- attributes = {
+ failure_attributes = {
bulk_import_entity_id: context.entity.id,
pipeline_class: pipeline,
pipeline_step: step,
@@ -108,16 +108,18 @@ module BulkImports
correlation_id_value: Labkit::Correlation::CorrelationId.current_or_new_id
}
- error(
- bulk_import_id: context.bulk_import_id,
- pipeline_step: step,
- exception_class: exception.class.to_s,
- exception_message: exception.message,
- message: "Pipeline failed",
- importer: 'gitlab_migration'
+ log_exception(
+ exception,
+ log_params(
+ {
+ bulk_import_id: context.bulk_import_id,
+ pipeline_step: step,
+ message: 'Pipeline failed'
+ }
+ )
)
- BulkImports::Failure.create(attributes)
+ BulkImports::Failure.create(failure_attributes)
end
def info(extra = {})
@@ -128,17 +130,15 @@ module BulkImports
logger.warn(log_params(extra))
end
- def error(extra = {})
- logger.error(log_params(extra))
- end
-
def log_params(extra)
defaults = {
bulk_import_id: context.bulk_import_id,
bulk_import_entity_id: context.entity.id,
bulk_import_entity_type: context.entity.source_type,
+ source_full_path: context.entity.source_full_path,
pipeline_class: pipeline,
context_extra: context.extra,
+ source_version: context.entity.bulk_import.source_version_info.to_s,
importer: 'gitlab_migration'
}
@@ -150,6 +150,19 @@ module BulkImports
def logger
@logger ||= Gitlab::Import::Logger.build
end
+
+ def log_exception(exception, payload)
+ Gitlab::ExceptionLogFormatter.format!(exception, payload)
+ logger.error(structured_payload(payload))
+ end
+
+ def structured_payload(payload = {})
+ context = Gitlab::ApplicationContext.current.merge(
+ 'class' => self.class.name
+ )
+
+ payload.stringify_keys.merge(context)
+ end
end
end
end
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb
index 924de132840..ae55dae1201 100644
--- a/lib/gitlab/diff/file_collection/base.rb
+++ b/lib/gitlab/diff/file_collection/base.rb
@@ -46,7 +46,9 @@ module Gitlab
# This is either the new path, otherwise the old path for the diff_file
def diff_file_paths
- diff_files.map(&:file_path)
+ diffs.map do |diff|
+ diff.new_path.presence || diff.old_path
+ end
end
# This is both the new and old paths for the diff_file
diff --git a/lib/gitlab/kas/client.rb b/lib/gitlab/kas/client.rb
index 753a185344e..768810d5545 100644
--- a/lib/gitlab/kas/client.rb
+++ b/lib/gitlab/kas/client.rb
@@ -64,7 +64,7 @@ module Gitlab
def credentials
if URI(Gitlab::Kas.internal_url).scheme == 'grpcs'
- GRPC::Core::ChannelCredentials.new
+ GRPC::Core::ChannelCredentials.new(::Gitlab::X509::Certificate.ca_certs_bundle)
else
:this_channel_is_insecure
end