Commit 07c7ba1b authored by Kamil Trzcinski's avatar Kamil Trzcinski

Allow to drop jobs for deleted projects

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