diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-12 15:13:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-12 15:13:54 +0000 |
commit | 98638cd5e43611aac2193a5c2f80f72374040430 (patch) | |
tree | 6605f0f284efed1d05708b3799f093eb5e305a8f /app/services | |
parent | 43d816ebc20da6ff959176248c70d8c4c7c9345a (diff) | |
download | gitlab-ce-98638cd5e43611aac2193a5c2f80f72374040430.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/ci/reset_skipped_jobs_service.rb | 32 | ||||
-rw-r--r-- | app/services/ci/runners/register_runner_service.rb | 4 | ||||
-rw-r--r-- | app/services/protected_branches/base_service.rb | 2 |
3 files changed, 29 insertions, 9 deletions
diff --git a/app/services/ci/reset_skipped_jobs_service.rb b/app/services/ci/reset_skipped_jobs_service.rb index eb809b0162c..cb793eb3e06 100644 --- a/app/services/ci/reset_skipped_jobs_service.rb +++ b/app/services/ci/reset_skipped_jobs_service.rb @@ -4,8 +4,10 @@ module Ci # This service resets skipped jobs so they can be processed again. # It affects the jobs that depend on the passed in job parameter. class ResetSkippedJobsService < ::BaseService - def execute(processable) - @processable = processable + def execute(processables) + @processables = Array.wrap(processables) + @pipeline = @processables.first.pipeline + @processable = @processables.first # Remove with FF `ci_support_reset_skipped_jobs_for_multiple_jobs` process_subsequent_jobs reset_source_bridge @@ -20,13 +22,13 @@ module Ci end def reset_source_bridge - @processable.pipeline.reset_source_bridge!(current_user) + @pipeline.reset_source_bridge!(current_user) end # rubocop: disable CodeReuse/ActiveRecord def dependent_jobs ordered_by_dag( - @processable.pipeline.processables + @pipeline.processables .from_union(needs_dependent_jobs, stage_dependent_jobs) .skipped .ordered_by_stage @@ -41,13 +43,27 @@ module Ci end def stage_dependent_jobs - @processable.pipeline.processables.after_stage(@processable.stage_idx) + if ::Feature.enabled?(:ci_support_reset_skipped_jobs_for_multiple_jobs, project) + # Get all jobs after the earliest stage of the inputted jobs + min_stage_idx = @processables.map(&:stage_idx).min + @pipeline.processables.after_stage(min_stage_idx) + else + @pipeline.processables.after_stage(@processable.stage_idx) + end end def needs_dependent_jobs - ::Gitlab::Ci::ProcessableObjectHierarchy.new( - ::Ci::Processable.where(id: @processable.id) - ).descendants + if ::Feature.enabled?(:ci_support_reset_skipped_jobs_for_multiple_jobs, project) + # We must include the hierarchy base here because @processables may include both a parent job + # and its dependents, and we do not want to exclude those dependents from being processed. + ::Gitlab::Ci::ProcessableObjectHierarchy.new( + ::Ci::Processable.where(id: @processables.map(&:id)) + ).base_and_descendants + else + ::Gitlab::Ci::ProcessableObjectHierarchy.new( + ::Ci::Processable.where(id: @processable.id) + ).descendants + end end def ordered_by_dag(jobs) diff --git a/app/services/ci/runners/register_runner_service.rb b/app/services/ci/runners/register_runner_service.rb index 8921acb9ff1..0c13c32e236 100644 --- a/app/services/ci/runners/register_runner_service.rb +++ b/app/services/ci/runners/register_runner_service.rb @@ -14,7 +14,9 @@ module Ci return ServiceResponse.error(message: 'invalid token supplied', http_status: :forbidden) unless attrs_from_token unless registration_token_allowed?(attrs_from_token) - return ServiceResponse.error(message: 'runner registration disallowed', http_status: :forbidden) + return ServiceResponse.error( + message: 'runner registration disallowed', + reason: :runner_registration_disallowed) end runner = ::Ci::Runner.new(attributes.merge(attrs_from_token)) diff --git a/app/services/protected_branches/base_service.rb b/app/services/protected_branches/base_service.rb index 6906ab2b642..0ab46bf236c 100644 --- a/app/services/protected_branches/base_service.rb +++ b/app/services/protected_branches/base_service.rb @@ -18,6 +18,8 @@ module ProtectedBranches def refresh_cache CacheService.new(@project_or_group, @current_user, @params).refresh + rescue StandardError => e + Gitlab::ErrorTracking.track_exception(e) end end end |