summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-09-26 08:56:10 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-09-26 08:56:10 +0000
commit6b35437099250f557bccaa8dc61eeb59c3420b0d (patch)
tree91db9645f8f274e9a090896f0e4cf28dd5b0a52f
parent923ad9a9e2ffca550a06d0cbbd89ac6f276c4605 (diff)
parentfefd61c1033496d7bd12e39f7a3fbad27305b92a (diff)
downloadgitlab-ce-6b35437099250f557bccaa8dc61eeb59c3420b0d.tar.gz
Merge branch 'fix-locked-shared-runners-problem' into 'master'
Fix locked shared runners problem Closes gitlab-runner#2782 See merge request gitlab-org/gitlab-ce!14483
-rw-r--r--app/models/ci/runner.rb2
-rw-r--r--changelogs/unreleased/fix-locked-shared-runners-problem.yml5
-rw-r--r--spec/models/ci/runner_spec.rb69
3 files changed, 24 insertions, 52 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index a0d07902ba2..c6509f89117 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -174,7 +174,7 @@ module Ci
end
def assignable_for?(project)
- !locked? || projects.exists?(id: project.id)
+ is_shared? || projects.exists?(id: project.id)
end
def accepting_tags?(build)
diff --git a/changelogs/unreleased/fix-locked-shared-runners-problem.yml b/changelogs/unreleased/fix-locked-shared-runners-problem.yml
new file mode 100644
index 00000000000..3e3cccf79eb
--- /dev/null
+++ b/changelogs/unreleased/fix-locked-shared-runners-problem.yml
@@ -0,0 +1,5 @@
+---
+title: Make locked setting of Runner to not affect jobs scheduling
+merge_request: 14483
+author:
+type: fixed
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index 2e686e515c5..584dfe9a5c1 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -183,75 +183,42 @@ describe Ci::Runner do
end
end
- context 'when runner is locked' do
+ context 'when runner is shared' do
before do
- runner.locked = true
+ runner.is_shared = true
+ build.project.runners = []
end
- shared_examples 'locked build picker' do
- context 'when runner cannot pick untagged jobs' do
- before do
- runner.run_untagged = false
- end
+ it 'can handle builds' do
+ expect(runner.can_pick?(build)).to be_truthy
+ end
- it 'cannot handle builds without tags' do
- expect(runner.can_pick?(build)).to be_falsey
- end
+ context 'when runner is locked' do
+ before do
+ runner.locked = true
end
- context 'when having runner tags' do
- before do
- runner.tag_list = %w(bb cc)
- end
-
- it 'cannot handle it for builds without matching tags' do
- build.tag_list = ['aa']
-
- expect(runner.can_pick?(build)).to be_falsey
- end
+ it 'can handle builds' do
+ expect(runner.can_pick?(build)).to be_truthy
end
end
+ end
- context 'when serving the same project' do
- it 'can handle it' do
+ context 'when runner is not shared' do
+ context 'when runner is assigned to a project' do
+ it 'can handle builds' do
expect(runner.can_pick?(build)).to be_truthy
end
-
- it_behaves_like 'locked build picker'
-
- context 'when having runner tags' do
- before do
- runner.tag_list = %w(bb cc)
- build.tag_list = ['bb']
- end
-
- it 'can handle it for matching tags' do
- expect(runner.can_pick?(build)).to be_truthy
- end
- end
end
- context 'serving a different project' do
+ context 'when runner is not assigned to a project' do
before do
- runner.runner_projects.destroy_all
+ build.project.runners = []
end
- it 'cannot handle it' do
+ it 'cannot handle builds' do
expect(runner.can_pick?(build)).to be_falsey
end
-
- it_behaves_like 'locked build picker'
-
- context 'when having runner tags' do
- before do
- runner.tag_list = %w(bb cc)
- build.tag_list = ['bb']
- end
-
- it 'cannot handle it for matching tags' do
- expect(runner.can_pick?(build)).to be_falsey
- end
- end
end
end