From 17ab40ca089e1aef61a83f77ab6df62a72f6ce06 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 26 Feb 2020 15:08:56 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/services/ci/create_job_artifacts_service.rb | 37 +++++++++++++++++-------- app/services/ci/retry_build_service.rb | 3 +- 2 files changed, 28 insertions(+), 12 deletions(-) (limited to 'app/services/ci') diff --git a/app/services/ci/create_job_artifacts_service.rb b/app/services/ci/create_job_artifacts_service.rb index e633dc7f633..3aa2b16bc73 100644 --- a/app/services/ci/create_job_artifacts_service.rb +++ b/app/services/ci/create_job_artifacts_service.rb @@ -1,8 +1,13 @@ # frozen_string_literal: true module Ci - class CreateJobArtifactsService + class CreateJobArtifactsService < ::BaseService ArtifactsExistError = Class.new(StandardError) + OBJECT_STORAGE_ERRORS = [ + Errno::EIO, + Google::Apis::ServerError, + Signet::RemoteServerError + ].freeze def execute(job, artifacts_file, params, metadata_file: nil) expire_in = params['expire_in'] || @@ -26,18 +31,20 @@ module Ci expire_in: expire_in) end - job.update(artifacts_expire_in: expire_in) - rescue ActiveRecord::RecordNotUnique => error - return true if sha256_matches_existing_artifact?(job, params['artifact_type'], artifacts_file) + if job.update(artifacts_expire_in: expire_in) + success + else + error(job.errors.messages, :bad_request) + end - Gitlab::ErrorTracking.track_exception(error, - job_id: job.id, - project_id: job.project_id, - uploading_type: params['artifact_type'] - ) + rescue ActiveRecord::RecordNotUnique => error + return success if sha256_matches_existing_artifact?(job, params['artifact_type'], artifacts_file) - job.errors.add(:base, 'another artifact of the same type already exists') - false + track_exception(error, job, params) + error('another artifact of the same type already exists', :bad_request) + rescue *OBJECT_STORAGE_ERRORS => error + track_exception(error, job, params) + error(error.message, :service_unavailable) end private @@ -48,5 +55,13 @@ module Ci existing_artifact.file_sha256 == artifacts_file.sha256 end + + def track_exception(error, job, params) + Gitlab::ErrorTracking.track_exception(error, + job_id: job.id, + project_id: job.project_id, + uploading_type: params['artifact_type'] + ) + end end end diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb index 838ed789155..87f818ad497 100644 --- a/app/services/ci/retry_build_service.rb +++ b/app/services/ci/retry_build_service.rb @@ -5,7 +5,8 @@ module Ci CLONE_ACCESSORS = %i[pipeline project ref tag options name allow_failure stage stage_id stage_idx trigger_request yaml_variables when environment coverage_regex - description tag_list protected needs resource_group scheduling_type].freeze + description tag_list protected needs_attributes + resource_group scheduling_type].freeze def execute(build) reprocess!(build).tap do |new_build| -- cgit v1.2.3