Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6c740324
Commit
6c740324
authored
Oct 03, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not process jobs when pipeline activity limit exceeded
parent
4adc2698
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
24 deletions
+6
-24
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+3
-2
ee/lib/ee/gitlab/ci/pipeline/chain/limit/activity.rb
ee/lib/ee/gitlab/ci/pipeline/chain/limit/activity.rb
+0
-9
spec/ee/spec/lib/ee/gitlab/ci/pipeline/chain/limit/activity_spec.rb
...ec/lib/ee/gitlab/ci/pipeline/chain/limit/activity_spec.rb
+1
-11
spec/ee/spec/services/ci/create_pipeline_service_spec.rb
spec/ee/spec/services/ci/create_pipeline_service_spec.rb
+2
-2
No files found.
app/models/ci/pipeline.rb
View file @
6c740324
...
@@ -5,6 +5,7 @@ module Ci
...
@@ -5,6 +5,7 @@ module Ci
include
Importable
include
Importable
include
AfterCommitQueue
include
AfterCommitQueue
include
Presentable
include
Presentable
include
Gitlab
::
OptimisticLocking
prepend
::
EE
::
Ci
::
Pipeline
prepend
::
EE
::
Ci
::
Pipeline
...
@@ -287,7 +288,7 @@ module Ci
...
@@ -287,7 +288,7 @@ module Ci
end
end
def
cancel_running
def
cancel_running
Gitlab
::
OptimisticLocking
.
retry
_lock
(
cancelable_statuses
)
do
|
cancelable
|
retry_optimistic
_lock
(
cancelable_statuses
)
do
|
cancelable
|
cancelable
.
find_each
do
|
job
|
cancelable
.
find_each
do
|
job
|
yield
(
job
)
if
block_given?
yield
(
job
)
if
block_given?
job
.
cancel
job
.
cancel
...
@@ -431,7 +432,7 @@ module Ci
...
@@ -431,7 +432,7 @@ module Ci
end
end
def
update_status
def
update_status
Gitlab
::
OptimisticLocking
.
retry
_lock
(
self
)
do
retry_optimistic
_lock
(
self
)
do
case
latest_builds_status
case
latest_builds_status
when
'pending'
then
enqueue
when
'pending'
then
enqueue
when
'running'
then
run
when
'running'
then
run
...
...
ee/lib/ee/gitlab/ci/pipeline/chain/limit/activity.rb
View file @
6c740324
...
@@ -18,18 +18,9 @@ module EE
...
@@ -18,18 +18,9 @@ module EE
def
perform!
def
perform!
return
unless
@limit
.
exceeded?
return
unless
@limit
.
exceeded?
@pipeline
.
cancel_running
retry_optimistic_lock
(
@pipeline
)
do
retry_optimistic_lock
(
@pipeline
)
do
@pipeline
.
drop!
(
:activity_limit_exceeded
)
@pipeline
.
drop!
(
:activity_limit_exceeded
)
end
end
# TODO, should we invalidate the pipeline
# while it is already persisted?
#
# Should we show info in the UI or alert/warning?
#
error
(
@limit
.
message
)
end
end
def
break?
def
break?
...
...
spec/ee/spec/lib/ee/gitlab/ci/pipeline/chain/limit/activity_spec.rb
View file @
6c740324
...
@@ -6,18 +6,13 @@ describe EE::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
...
@@ -6,18 +6,13 @@ describe EE::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
set
(
:user
)
{
create
(
:user
)
}
set
(
:user
)
{
create
(
:user
)
}
let
(
:command
)
do
let
(
:command
)
do
double
(
'command'
,
project:
project
,
double
(
'command'
,
project:
project
,
current_user:
user
)
current_user:
user
)
end
end
let
(
:pipeline
)
do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
)
create
(
:ci_pipeline
,
project:
project
)
end
end
before
do
create
(
:ci_build
,
pipeline:
pipeline
)
end
let
(
:step
)
{
described_class
.
new
(
pipeline
,
command
)
}
let
(
:step
)
{
described_class
.
new
(
pipeline
,
command
)
}
context
'when active pipelines limit is exceeded'
do
context
'when active pipelines limit is exceeded'
do
...
@@ -38,11 +33,6 @@ describe EE::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
...
@@ -38,11 +33,6 @@ describe EE::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
expect
(
pipeline
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
end
end
it
'cancels all pipeline jobs'
do
expect
(
pipeline
.
statuses
).
not_to
be_empty
expect
(
pipeline
.
statuses
).
to
all
(
be_canceled
)
end
it
'breaks the chain'
do
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
expect
(
step
.
break?
).
to
be
true
end
end
...
...
spec/ee/spec/services/ci/create_pipeline_service_spec.rb
View file @
6c740324
...
@@ -37,13 +37,13 @@ describe Ci::CreatePipelineService, '#execute' do
...
@@ -37,13 +37,13 @@ describe Ci::CreatePipelineService, '#execute' do
create
(
:ci_pipeline
,
project:
project
,
status:
'running'
)
create
(
:ci_pipeline
,
project:
project
,
status:
'running'
)
end
end
it
'drops the pipeline and
cancels all
jobs'
do
it
'drops the pipeline and
does not process
jobs'
do
pipeline
=
create_pipeline!
pipeline
=
create_pipeline!
expect
(
pipeline
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
expect
(
pipeline
).
to
be_failed
expect
(
pipeline
).
to
be_failed
expect
(
pipeline
.
statuses
).
not_to
be_empty
expect
(
pipeline
.
statuses
).
not_to
be_empty
expect
(
pipeline
.
statuses
).
to
all
(
be_c
ancel
ed
)
expect
(
pipeline
.
statuses
).
to
all
(
be_c
reat
ed
)
expect
(
pipeline
.
activity_limit_exceeded?
).
to
be
true
expect
(
pipeline
.
activity_limit_exceeded?
).
to
be
true
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment