BigW Consortium Gitlab

Commit 7d537e59 by Kamil Trzciński Committed by Jarka Kadlecova

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
parent 3c32ffd5
...@@ -174,7 +174,7 @@ module Ci ...@@ -174,7 +174,7 @@ module Ci
end end
def assignable_for?(project) def assignable_for?(project)
!locked? || projects.exists?(id: project.id) is_shared? || projects.exists?(id: project.id)
end end
def accepting_tags?(build) def accepting_tags?(build)
......
---
title: Make locked setting of Runner to not affect jobs scheduling
merge_request: 14483
author:
type: fixed
...@@ -183,75 +183,42 @@ describe Ci::Runner do ...@@ -183,75 +183,42 @@ describe Ci::Runner do
end end
end end
context 'when runner is locked' do context 'when runner is shared' do
before do before do
runner.locked = true runner.is_shared = true
build.project.runners = []
end end
shared_examples 'locked build picker' do it 'can handle builds' do
context 'when runner cannot pick untagged jobs' do expect(runner.can_pick?(build)).to be_truthy
before do end
runner.run_untagged = false
end
it 'cannot handle builds without tags' do context 'when runner is locked' do
expect(runner.can_pick?(build)).to be_falsey before do
end runner.locked = true
end end
context 'when having runner tags' do it 'can handle builds' do
before do expect(runner.can_pick?(build)).to be_truthy
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
end end
end end
end
context 'when serving the same project' do context 'when runner is not shared' do
it 'can handle it' do context 'when runner is assigned to a project' do
it 'can handle builds' do
expect(runner.can_pick?(build)).to be_truthy expect(runner.can_pick?(build)).to be_truthy
end 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 end
context 'serving a different project' do context 'when runner is not assigned to a project' do
before do before do
runner.runner_projects.destroy_all build.project.runners = []
end end
it 'cannot handle it' do it 'cannot handle builds' do
expect(runner.can_pick?(build)).to be_falsey expect(runner.can_pick?(build)).to be_falsey
end 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
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