summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2017-03-03 00:43:39 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2017-03-03 00:43:39 +0100
commit4d4e99a2f163408de44d39ea98131a4231667c24 (patch)
tree0b3544b81e50abefb5f6fc6607901484f708a1f4
parentb66fe22a09d3969cd44c7eadab67eee8370fb998 (diff)
downloadgitlab-ce-27523-make-stuck-build-detection-more-performant.tar.gz
Renable StuckCiBuildsWorker to StucjCiJobsWorker27523-make-stuck-build-detection-more-performant
-rw-r--r--app/workers/stuck_ci_jobs_worker.rb (renamed from app/workers/stuck_ci_builds_worker.rb)2
-rw-r--r--config/gitlab.yml.example4
-rw-r--r--config/initializers/1_settings.rb6
-rw-r--r--spec/workers/stuck_ci_jobs_worker_spec.rb (renamed from spec/workers/stuck_ci_builds_worker_spec.rb)58
4 files changed, 35 insertions, 35 deletions
diff --git a/app/workers/stuck_ci_builds_worker.rb b/app/workers/stuck_ci_jobs_worker.rb
index 0c51c34a47f..ae8c980c9e4 100644
--- a/app/workers/stuck_ci_builds_worker.rb
+++ b/app/workers/stuck_ci_jobs_worker.rb
@@ -1,4 +1,4 @@
-class StuckCiBuildsWorker
+class StuckCiJobsWorker
include Sidekiq::Worker
include CronjobQueue
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index b4f47b30622..8f99a4d541f 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -177,8 +177,8 @@ production: &base
# Periodically executed jobs, to self-heal Gitlab, do external synchronizations, etc.
# Please read here for more information: https://github.com/ondrejbartas/sidekiq-cron#adding-cron-job
cron_jobs:
- # Flag stuck CI builds as failed
- stuck_ci_builds_worker:
+ # Flag stuck CI jobs as failed
+ stuck_ci_jobs_worker:
cron: "0 * * * *"
# Remove expired build artifacts
expire_build_artifacts_worker:
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 3ec57c5bb52..5aeaa7eab81 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -308,9 +308,9 @@ Settings.gravatar['host'] = Settings.host_without_www(Settings.gravatar[
# Cron Jobs
#
Settings['cron_jobs'] ||= Settingslogic.new({})
-Settings.cron_jobs['stuck_ci_builds_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['stuck_ci_builds_worker']['cron'] ||= '0 * * * *'
-Settings.cron_jobs['stuck_ci_builds_worker']['job_class'] = 'StuckCiBuildsWorker'
+Settings.cron_jobs['stuck_ci_jobs_worker'] ||= Settingslogic.new({})
+Settings.cron_jobs['stuck_ci_jobs_worker']['cron'] ||= '0 * * * *'
+Settings.cron_jobs['stuck_ci_jobs_worker']['job_class'] = 'StuckCiJobsWorker'
Settings.cron_jobs['expire_build_artifacts_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['expire_build_artifacts_worker']['cron'] ||= '50 * * * *'
Settings.cron_jobs['expire_build_artifacts_worker']['job_class'] = 'ExpireBuildArtifactsWorker'
diff --git a/spec/workers/stuck_ci_builds_worker_spec.rb b/spec/workers/stuck_ci_jobs_worker_spec.rb
index 82bdc2b14f3..8434b0c8e5b 100644
--- a/spec/workers/stuck_ci_builds_worker_spec.rb
+++ b/spec/workers/stuck_ci_jobs_worker_spec.rb
@@ -1,91 +1,91 @@
require 'spec_helper'
-describe StuckCiBuildsWorker do
+describe StuckCiJobsWorker do
let!(:runner) { create :ci_runner }
- let!(:build) { create :ci_build, runner: runner }
+ let!(:job) { create :ci_build, runner: runner }
let(:worker) { described_class.new }
let(:exclusive_lease_uuid) { SecureRandom.uuid }
subject do
- build.reload
- build.status
+ job.reload
+ job.status
end
before do
- build.update!(status: status, updated_at: updated_at)
+ job.update!(status: status, updated_at: updated_at)
allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain).and_return(exclusive_lease_uuid)
end
- shared_examples 'build is dropped' do
+ shared_examples 'job is dropped' do
it 'changes status' do
worker.perform
is_expected.to eq('failed')
end
end
- shared_examples 'build is unchanged' do
+ shared_examples 'job is unchanged' do
it "doesn't change status" do
worker.perform
is_expected.to eq(status)
end
end
- context 'when build is pending' do
+ context 'when job is pending' do
let(:status) { 'pending' }
- context 'when build is not stuck' do
+ context 'when job is not stuck' do
before { allow_any_instance_of(Ci::Build).to receive(:stuck?).and_return(false) }
- context 'when build was not updated for more than 1 day ago' do
+ context 'when job was not updated for more than 1 day ago' do
let(:updated_at) { 2.days.ago }
- it_behaves_like 'build is dropped'
+ it_behaves_like 'job is dropped'
end
- context 'when build was updated in less than 1 day ago' do
+ context 'when job was updated in less than 1 day ago' do
let(:updated_at) { 6.hours.ago }
- it_behaves_like 'build is unchanged'
+ it_behaves_like 'job is unchanged'
end
- context 'when build was not updated for more than 1 hour ago' do
+ context 'when job was not updated for more than 1 hour ago' do
let(:updated_at) { 2.hours.ago }
- it_behaves_like 'build is unchanged'
+ it_behaves_like 'job is unchanged'
end
end
- context 'when build is stuck' do
+ context 'when job is stuck' do
before { allow_any_instance_of(Ci::Build).to receive(:stuck?).and_return(true) }
- context 'when build was not updated for more than 1 hour ago' do
+ context 'when job was not updated for more than 1 hour ago' do
let(:updated_at) { 2.hours.ago }
- it_behaves_like 'build is dropped'
+ it_behaves_like 'job is dropped'
end
- context 'when build was updated in less than 1 hour ago' do
+ context 'when job was updated in less than 1 hour ago' do
let(:updated_at) { 30.minutes.ago }
- it_behaves_like 'build is unchanged'
+ it_behaves_like 'job is unchanged'
end
end
end
- context 'when build is running' do
+ context 'when job is running' do
let(:status) { 'running' }
- context 'when build was not updated for more than 1 hour ago' do
+ context 'when job was not updated for more than 1 hour ago' do
let(:updated_at) { 2.hours.ago }
- it_behaves_like 'build is dropped'
+ it_behaves_like 'job is dropped'
end
- context 'when build was updated in less than 1 hour ago' do
+ context 'when job was updated in less than 1 hour ago' do
let(:updated_at) { 30.minutes.ago }
- it_behaves_like 'build is unchanged'
+ it_behaves_like 'job is unchanged'
end
end
%w(success skipped failed canceled).each do |status|
- context "when build is #{status}" do
+ context "when job is #{status}" do
let(:status) { status }
let(:updated_at) { 2.days.ago }
- it_behaves_like 'build is unchanged'
+ it_behaves_like 'job is unchanged'
end
end
@@ -93,9 +93,9 @@ describe StuckCiBuildsWorker do
let(:status) { 'running' }
let(:updated_at) { 2.days.ago }
- before { build.project.update(pending_delete: true) }
+ before { job.project.update(pending_delete: true) }
- it 'does not drop build' do
+ it 'does not drop job' do
expect_any_instance_of(Ci::Build).not_to receive(:drop)
worker.perform
end