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
9db81275
Commit
9db81275
authored
Oct 31, 2019
by
Fabio Pitino
Committed by
Kamil Trzciński
Oct 31, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log when a pipeline limit is hit
Use existing Sentry exception logging for all existing limits
parent
8bc9939f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
105 additions
and
18 deletions
+105
-18
ee/lib/ee/gitlab/ci/limit.rb
ee/lib/ee/gitlab/ci/limit.rb
+9
-0
ee/lib/ee/gitlab/ci/pipeline/chain/limit/activity.rb
ee/lib/ee/gitlab/ci/pipeline/chain/limit/activity.rb
+1
-0
ee/lib/ee/gitlab/ci/pipeline/chain/limit/job_activity.rb
ee/lib/ee/gitlab/ci/pipeline/chain/limit/job_activity.rb
+1
-0
ee/lib/ee/gitlab/ci/pipeline/chain/limit/size.rb
ee/lib/ee/gitlab/ci/pipeline/chain/limit/size.rb
+1
-0
ee/spec/lib/gitlab/ci/pipeline/chain/limit/activity_spec.rb
ee/spec/lib/gitlab/ci/pipeline/chain/limit/activity_spec.rb
+29
-6
ee/spec/lib/gitlab/ci/pipeline/chain/limit/job_activity_spec.rb
...c/lib/gitlab/ci/pipeline/chain/limit/job_activity_spec.rb
+29
-6
ee/spec/lib/gitlab/ci/pipeline/chain/limit/size_spec.rb
ee/spec/lib/gitlab/ci/pipeline/chain/limit/size_spec.rb
+35
-6
No files found.
ee/lib/ee/gitlab/ci/limit.rb
View file @
9db81275
...
...
@@ -7,6 +7,8 @@ module EE
# Abstract base class for CI/CD Quotas
#
class
Limit
LimitExceededError
=
Class
.
new
(
StandardError
)
def
initialize
(
_context
,
_resource
)
end
...
...
@@ -21,6 +23,13 @@ module EE
def
message
raise
NotImplementedError
end
def
log_error!
(
extra_context
=
{})
error
=
LimitExceededError
.
new
(
message
)
# TODO: change this to Gitlab::Sentry.log_exception(error, extra_context)
# https://gitlab.com/gitlab-org/gitlab/issues/32906
::
Gitlab
::
Sentry
.
track_acceptable_exception
(
error
,
extra:
extra_context
)
end
end
end
end
...
...
ee/lib/ee/gitlab/ci/pipeline/chain/limit/activity.rb
View file @
9db81275
...
...
@@ -27,6 +27,7 @@ module EE
retry_optimistic_lock
(
pipeline
)
do
pipeline
.
drop!
(
:activity_limit_exceeded
)
limit
.
log_error!
(
project_id:
project
.
id
,
plan:
project
.
namespace
.
actual_plan_name
)
end
end
...
...
ee/lib/ee/gitlab/ci/pipeline/chain/limit/job_activity.rb
View file @
9db81275
...
...
@@ -27,6 +27,7 @@ module EE
retry_optimistic_lock
(
pipeline
)
do
pipeline
.
drop!
(
:job_activity_limit_exceeded
)
limit
.
log_error!
(
project_id:
project
.
id
,
plan:
project
.
namespace
.
actual_plan_name
)
end
end
...
...
ee/lib/ee/gitlab/ci/pipeline/chain/limit/size.rb
View file @
9db81275
...
...
@@ -28,6 +28,7 @@ module EE
pipeline
.
drop!
(
:size_limit_exceeded
)
end
limit
.
log_error!
(
project_id:
project
.
id
,
plan:
project
.
namespace
.
actual_plan_name
)
error
(
limit
.
message
)
end
...
...
ee/spec/lib/gitlab/ci/pipeline/chain/limit/activity_spec.rb
View file @
9db81275
...
...
@@ -17,6 +17,8 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
let
(
:step
)
{
described_class
.
new
(
pipeline
,
command
)
}
subject
{
step
.
perform!
}
context
'when active pipelines limit is exceeded'
do
before
do
gold_plan
=
create
(
:gold_plan
,
active_pipelines_limit:
1
)
...
...
@@ -24,38 +26,59 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
create
(
:ci_pipeline
,
project:
project
,
status:
'pending'
)
create
(
:ci_pipeline
,
project:
project
,
status:
'running'
)
step
.
perform!
end
it
'drops the pipeline'
do
subject
expect
(
pipeline
.
reload
).
to
be_failed
end
it
'persists the pipeline'
do
subject
expect
(
pipeline
).
to
be_persisted
end
it
'breaks the chain'
do
subject
expect
(
step
.
break?
).
to
be
true
end
it
'sets a valid failure reason'
do
subject
expect
(
pipeline
.
activity_limit_exceeded?
).
to
be
true
end
end
context
'when pipeline activity limit is not exceeded'
do
before
do
step
.
perform!
it
'logs the error'
do
expect
(
Gitlab
::
Sentry
).
to
receive
(
:track_acceptable_exception
).
with
(
instance_of
(
EE
::
Gitlab
::
Ci
::
Limit
::
LimitExceededError
),
extra:
{
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
}
)
subject
end
end
context
'when pipeline activity limit is not exceeded'
do
it
'does not break the chain'
do
subject
expect
(
step
.
break?
).
to
be
false
end
it
'does not invalidate the pipeline'
do
subject
expect
(
pipeline
.
errors
).
to
be_empty
end
it
'does not log any error'
do
expect
(
Gitlab
::
Sentry
).
not_to
receive
(
:track_acceptable_exception
)
subject
end
end
end
ee/spec/lib/gitlab/ci/pipeline/chain/limit/job_activity_spec.rb
View file @
9db81275
...
...
@@ -17,6 +17,8 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity do
let
(
:step
)
{
described_class
.
new
(
pipeline
,
command
)
}
subject
{
step
.
perform!
}
context
'when active jobs limit is exceeded'
do
before
do
gold_plan
=
create
(
:gold_plan
,
active_jobs_limit:
2
)
...
...
@@ -26,38 +28,59 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity do
create
(
:ci_build
,
pipeline:
pipeline
)
create
(
:ci_build
,
pipeline:
pipeline
)
create
(
:ci_build
,
pipeline:
pipeline
)
step
.
perform!
end
it
'drops the pipeline'
do
subject
expect
(
pipeline
.
reload
).
to
be_failed
end
it
'persists the pipeline'
do
subject
expect
(
pipeline
).
to
be_persisted
end
it
'breaks the chain'
do
subject
expect
(
step
.
break?
).
to
be
true
end
it
'sets a valid failure reason'
do
subject
expect
(
pipeline
.
job_activity_limit_exceeded?
).
to
be
true
end
end
context
'when job activity limit is not exceeded'
do
before
do
step
.
perform!
it
'logs the error'
do
expect
(
Gitlab
::
Sentry
).
to
receive
(
:track_acceptable_exception
).
with
(
instance_of
(
EE
::
Gitlab
::
Ci
::
Limit
::
LimitExceededError
),
extra:
{
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
}
)
subject
end
end
context
'when job activity limit is not exceeded'
do
it
'does not break the chain'
do
subject
expect
(
step
.
break?
).
to
be
false
end
it
'does not invalidate the pipeline'
do
subject
expect
(
pipeline
.
errors
).
to
be_empty
end
it
'does not log any error'
do
expect
(
Gitlab
::
Sentry
).
not_to
receive
(
:track_acceptable_exception
)
subject
end
end
end
ee/spec/lib/gitlab/ci/pipeline/chain/limit/size_spec.rb
View file @
9db81275
...
...
@@ -19,12 +19,12 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do
let
(
:step
)
{
described_class
.
new
(
pipeline
,
command
)
}
subject
{
step
.
perform!
}
context
'when pipeline size limit is exceeded'
do
before
do
gold_plan
=
create
(
:gold_plan
,
pipeline_size_limit:
1
)
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
gold_plan
)
step
.
perform!
end
let
(
:pipeline
)
do
...
...
@@ -42,25 +42,44 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do
end
it
'drops the pipeline'
do
subject
expect
(
pipeline
.
reload
).
to
be_failed
end
it
'persists the pipeline'
do
subject
expect
(
pipeline
).
to
be_persisted
end
it
'breaks the chain'
do
subject
expect
(
step
.
break?
).
to
be
true
end
it
'sets a valid failure reason'
do
subject
expect
(
pipeline
.
size_limit_exceeded?
).
to
be
true
end
it
'appends validation error'
do
subject
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
'Pipeline size limit exceeded by 1 job!'
end
it
'logs the error'
do
expect
(
Gitlab
::
Sentry
).
to
receive
(
:track_acceptable_exception
).
with
(
instance_of
(
EE
::
Gitlab
::
Ci
::
Limit
::
LimitExceededError
),
extra:
{
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
}
)
subject
end
end
context
'when not saving incomplete pipelines'
do
...
...
@@ -71,26 +90,36 @@ describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do
end
it
'does not drop the pipeline'
do
subject
expect
(
pipeline
).
not_to
be_failed
end
it
'breaks the chain'
do
subject
expect
(
step
.
break?
).
to
be
true
end
end
end
context
'when pipeline size limit is not exceeded'
do
before
do
step
.
perform!
end
it
'does not break the chain'
do
subject
expect
(
step
.
break?
).
to
be
false
end
it
'does not persist the pipeline'
do
subject
expect
(
pipeline
).
not_to
be_persisted
end
it
'does not log any error'
do
expect
(
Gitlab
::
Sentry
).
not_to
receive
(
:track_acceptable_exception
)
subject
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