Skip to content
Snippets Groups Projects
Commit e6d66c4d authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Don't fail builds for projects that are deleted when they are stuck

parent b4e84809
No related branches found
No related tags found
No related merge requests found
Loading
@@ -21,6 +21,7 @@ v 8.9.0 (unreleased)
Loading
@@ -21,6 +21,7 @@ v 8.9.0 (unreleased)
- Redesign navigation for project pages - Redesign navigation for project pages
- Fix groups API to list only user's accessible projects - Fix groups API to list only user's accessible projects
- Redesign account and email confirmation emails - Redesign account and email confirmation emails
- Don't fail builds for projects that are deleted
- `git clone https://host/namespace/project` now works, in addition to using the `.git` suffix - `git clone https://host/namespace/project` now works, in addition to using the `.git` suffix
- Bump nokogiri to 1.6.8 - Bump nokogiri to 1.6.8
- Use gitlab-shell v3.0.0 - Use gitlab-shell v3.0.0
Loading
Loading
Loading
@@ -6,7 +6,7 @@ class StuckCiBuildsWorker
Loading
@@ -6,7 +6,7 @@ class StuckCiBuildsWorker
def perform def perform
Rails.logger.info 'Cleaning stuck builds' Rails.logger.info 'Cleaning stuck builds'
   
builds = Ci::Build.running_or_pending.where('updated_at < ?', BUILD_STUCK_TIMEOUT.ago) builds = Ci::Build.joins(:project).running_or_pending.where('ci_builds.updated_at < ?', BUILD_STUCK_TIMEOUT.ago)
builds.find_each(batch_size: 50).each do |build| builds.find_each(batch_size: 50).each do |build|
Rails.logger.debug "Dropping stuck #{build.status} build #{build.id} for runner #{build.runner_id}" Rails.logger.debug "Dropping stuck #{build.status} build #{build.id} for runner #{build.runner_id}"
build.drop build.drop
Loading
Loading
Loading
@@ -2,6 +2,7 @@ require "spec_helper"
Loading
@@ -2,6 +2,7 @@ require "spec_helper"
   
describe StuckCiBuildsWorker do describe StuckCiBuildsWorker do
let!(:build) { create :ci_build } let!(:build) { create :ci_build }
let(:worker) { described_class.new }
   
subject do subject do
build.reload build.reload
Loading
@@ -16,13 +17,13 @@ describe StuckCiBuildsWorker do
Loading
@@ -16,13 +17,13 @@ describe StuckCiBuildsWorker do
   
it 'gets dropped if it was updated over 2 days ago' do it 'gets dropped if it was updated over 2 days ago' do
build.update!(updated_at: 2.days.ago) build.update!(updated_at: 2.days.ago)
StuckCiBuildsWorker.new.perform worker.perform
is_expected.to eq('failed') is_expected.to eq('failed')
end end
   
it "is still #{status}" do it "is still #{status}" do
build.update!(updated_at: 1.minute.ago) build.update!(updated_at: 1.minute.ago)
StuckCiBuildsWorker.new.perform worker.perform
is_expected.to eq(status) is_expected.to eq(status)
end end
end end
Loading
@@ -36,9 +37,21 @@ describe StuckCiBuildsWorker do
Loading
@@ -36,9 +37,21 @@ describe StuckCiBuildsWorker do
   
it "is still #{status}" do it "is still #{status}" do
build.update!(updated_at: 2.days.ago) build.update!(updated_at: 2.days.ago)
StuckCiBuildsWorker.new.perform worker.perform
is_expected.to eq(status) is_expected.to eq(status)
end end
end end
end end
context "for deleted project" do
before do
build.update!(status: :running, updated_at: 2.days.ago)
build.project.update(pending_delete: true)
end
it "does not drop build" do
expect_any_instance_of(Ci::Build).not_to receive(:drop)
worker.perform
end
end
end end
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