Skip to content
Snippets Groups Projects
Commit 07c7ba1b authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Allow to drop jobs for deleted projects

parent d58bab4a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -104,6 +104,7 @@ module Ci
end
 
before_transition any => [:failed] do |build|
next unless build.project
next if build.retries_max.zero?
 
if build.retries_count < build.retries_max
Loading
Loading
Loading
Loading
@@ -17,6 +17,7 @@ class CommitStatus < ActiveRecord::Base
validates :name, presence: true, unless: :importing?
 
alias_attribute :author, :user
alias_attribute :pipeline_id, :commit_id
 
scope :failed_but_allowed, -> do
where(allow_failure: true, status: [:failed, :canceled])
Loading
Loading
@@ -103,26 +104,29 @@ class CommitStatus < ActiveRecord::Base
end
 
after_transition do |commit_status, transition|
next unless commit_status.project
next if transition.loopback?
 
commit_status.run_after_commit do
if pipeline
if pipeline_id
if complete? || manual?
PipelineProcessWorker.perform_async(pipeline.id)
PipelineProcessWorker.perform_async(pipeline_id)
else
PipelineUpdateWorker.perform_async(pipeline.id)
PipelineUpdateWorker.perform_async(pipeline_id)
end
end
 
StageUpdateWorker.perform_async(commit_status.stage_id)
ExpireJobCacheWorker.perform_async(commit_status.id)
StageUpdateWorker.perform_async(stage_id)
ExpireJobCacheWorker.perform_async(id)
end
end
 
after_transition any => :failed do |commit_status|
next unless commit_status.project
commit_status.run_after_commit do
MergeRequests::AddTodoWhenBuildFailsService
.new(pipeline.project, nil).execute(self)
.new(project, nil).execute(self)
end
end
end
Loading
Loading
Loading
Loading
@@ -48,7 +48,6 @@ class StuckCiJobsWorker
loop do
jobs = Ci::Build.where(status: status)
.where('ci_builds.updated_at < ?', timeout.ago)
.joins(:project).merge(Project.without_deleted)
.includes(:tags, :runner, project: :namespace)
.limit(100)
.to_a
Loading
Loading
@@ -67,4 +66,3 @@ class StuckCiJobsWorker
end
end
end
Loading
Loading
@@ -105,8 +105,8 @@ describe StuckCiJobsWorker do
job.project.update(pending_delete: true)
end
 
it 'does not drop job' do
expect_any_instance_of(Ci::Build).not_to receive(:drop)
it 'does drop job' do
expect_any_instance_of(Ci::Build).to receive(:drop)
worker.perform
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment