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
ae2b035e
Commit
ae2b035e
authored
Jul 28, 2021
by
Avielle Wolfe
Committed by
Kamil Trzciński
Jul 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log data for determining global pipeline size limit
parent
23852b6c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
87 additions
and
17 deletions
+87
-17
ee/lib/ee/gitlab/ci/pipeline/chain/limit/size.rb
ee/lib/ee/gitlab/ci/pipeline/chain/limit/size.rb
+17
-4
ee/lib/ee/gitlab/ci/pipeline/quota/size.rb
ee/lib/ee/gitlab/ci/pipeline/quota/size.rb
+6
-2
ee/spec/lib/ee/gitlab/ci/pipeline/quota/size_spec.rb
ee/spec/lib/ee/gitlab/ci/pipeline/quota/size_spec.rb
+23
-1
ee/spec/lib/gitlab/ci/pipeline/chain/limit/activity_spec.rb
ee/spec/lib/gitlab/ci/pipeline/chain/limit/activity_spec.rb
+1
-1
ee/spec/lib/gitlab/ci/pipeline/chain/limit/job_activity_spec.rb
...c/lib/gitlab/ci/pipeline/chain/limit/job_activity_spec.rb
+1
-1
ee/spec/lib/gitlab/ci/pipeline/chain/limit/size_spec.rb
ee/spec/lib/gitlab/ci/pipeline/chain/limit/size_spec.rb
+30
-2
lib/gitlab/ci/limit.rb
lib/gitlab/ci/limit.rb
+7
-4
lib/gitlab/ci/pipeline/metrics.rb
lib/gitlab/ci/pipeline/metrics.rb
+1
-1
spec/lib/gitlab/ci/pipeline/chain/limit/deployments_spec.rb
spec/lib/gitlab/ci/pipeline/chain/limit/deployments_spec.rb
+1
-1
No files found.
ee/lib/ee/gitlab/ci/pipeline/chain/limit/size.rb
View file @
ae2b035e
...
...
@@ -22,16 +22,29 @@ module EE
override
:perform!
def
perform!
return
unless
limit
.
exceeded?
limit
.
log_error!
(
project_id:
project
.
id
,
plan:
project
.
actual_plan_name
)
error
(
limit
.
message
,
drop_reason: :size_limit_exceeded
)
if
limit
.
exceeded?
limit
.
log_error!
(
log_attrs
)
error
(
limit
.
message
,
drop_reason: :size_limit_exceeded
)
elsif
limit
.
log_exceeded_limit?
limit
.
log_error!
(
log_attrs
)
end
end
override
:break?
def
break?
limit
.
exceeded?
end
private
def
log_attrs
{
pipeline_source:
pipeline
.
source
,
plan:
project
.
actual_plan_name
,
project_id:
project
.
id
,
project_full_path:
project
.
full_path
}
end
end
end
end
...
...
ee/lib/ee/gitlab/ci/pipeline/quota/size.rb
View file @
ae2b035e
...
...
@@ -9,6 +9,8 @@ module EE
include
::
Gitlab
::
Utils
::
StrongMemoize
include
ActionView
::
Helpers
::
TextHelper
LOGGABLE_JOBS_COUNT
=
2000
# log large pipelines to determine a future global pipeline size limit
def
initialize
(
namespace
,
pipeline
,
command
)
@namespace
=
namespace
@pipeline
=
pipeline
...
...
@@ -25,9 +27,11 @@ module EE
seeds_size
>
ci_pipeline_size_limit
end
def
message
return
unless
exceeded?
def
log_exceeded_limit?
seeds_size
>
LOGGABLE_JOBS_COUNT
end
def
message
"Pipeline has too many jobs! Requested
#{
seeds_size
}
, but the limit is
#{
ci_pipeline_size_limit
}
."
end
...
...
ee/spec/lib/ee/gitlab/ci/pipeline/quota/size_spec.rb
View file @
ae2b035e
...
...
@@ -84,10 +84,32 @@ RSpec.describe EE::Gitlab::Ci::Pipeline::Quota::Size do
context
'when limit is exceeded'
do
include_context
'pipeline size limit exceeded'
it
'returns info
r
about pipeline size limit exceeded'
do
it
'returns info about pipeline size limit exceeded'
do
expect
(
subject
.
message
)
.
to
eq
"Pipeline has too many jobs! Requested 2, but the limit is 1."
end
end
end
describe
'#log_exceeded_limit?'
do
context
'when there are more than 2000 jobs in the pipeline'
do
let
(
:command
)
do
double
(
:command
,
pipeline_seed:
double
(
:pipeline_seed
,
size:
2001
))
end
it
'returns true'
do
expect
(
subject
.
log_exceeded_limit?
).
to
be_truthy
end
end
context
'when there are 2000 or less jobs in the pipeline'
do
let
(
:command
)
do
double
(
:command
,
pipeline_seed:
double
(
:pipeline_seed
,
size:
2000
))
end
it
'returns false'
do
expect
(
subject
.
log_exceeded_limit?
).
to
be_falsey
end
end
end
end
ee/spec/lib/gitlab/ci/pipeline/chain/limit/activity_spec.rb
View file @
ae2b035e
...
...
@@ -54,7 +54,7 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::Activity do
end
it
'logs the error'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:
track
_exception
).
with
(
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:
log
_exception
).
with
(
instance_of
(
Gitlab
::
Ci
::
Limit
::
LimitExceededError
),
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
)
...
...
ee/spec/lib/gitlab/ci/pipeline/chain/limit/job_activity_spec.rb
View file @
ae2b035e
...
...
@@ -56,7 +56,7 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::JobActivity do
end
it
'logs the error'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:
track
_exception
).
with
(
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:
log
_exception
).
with
(
instance_of
(
Gitlab
::
Ci
::
Limit
::
LimitExceededError
),
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
)
...
...
ee/spec/lib/gitlab/ci/pipeline/chain/limit/size_spec.rb
View file @
ae2b035e
...
...
@@ -68,9 +68,10 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do
end
it
'logs the error'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:
track
_exception
).
with
(
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:
log
_exception
).
with
(
instance_of
(
Gitlab
::
Ci
::
Limit
::
LimitExceededError
),
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
,
project_full_path:
project
.
full_path
,
pipeline_source:
pipeline
.
source
)
subject
...
...
@@ -132,4 +133,31 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::Size do
subject
end
end
context
'when pipeline size limit is disabled'
do
before
do
ultimate_plan
=
create
(
:ultimate_plan
)
create
(
:plan_limits
,
plan:
ultimate_plan
,
ci_pipeline_size:
0
)
create
(
:gitlab_subscription
,
namespace:
namespace
,
hosted_plan:
ultimate_plan
)
end
context
'when global pipeline size limit is exceeded'
do
let
(
:command
)
do
double
(
:command
,
project:
project
,
current_user:
user
,
pipeline_seed:
double
(
:seed
,
size:
2001
))
end
it
'logs the pipeline'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:log_exception
).
with
(
instance_of
(
Gitlab
::
Ci
::
Limit
::
LimitExceededError
),
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
,
project_full_path:
project
.
full_path
,
pipeline_source:
pipeline
.
source
)
subject
end
end
end
end
lib/gitlab/ci/limit.rb
View file @
ae2b035e
...
...
@@ -24,10 +24,13 @@ module Gitlab
end
def
log_error!
(
extra_context
=
{})
error
=
LimitExceededError
.
new
(
message
)
# TODO: change this to Gitlab::ErrorTracking.log_exception(error, extra_context)
# https://gitlab.com/gitlab-org/gitlab/issues/32906
::
Gitlab
::
ErrorTracking
.
track_exception
(
error
,
extra_context
)
::
Gitlab
::
ErrorTracking
.
log_exception
(
limit_exceeded_error
,
extra_context
)
end
protected
def
limit_exceeded_error
LimitExceededError
.
new
(
message
)
end
end
end
...
...
lib/gitlab/ci/pipeline/metrics.rb
View file @
ae2b035e
...
...
@@ -24,7 +24,7 @@ module Gitlab
name
=
:gitlab_ci_pipeline_size_builds
comment
=
'Pipeline size'
labels
=
{
source:
nil
}
buckets
=
[
0
,
1
,
5
,
10
,
20
,
50
,
100
,
200
,
500
,
1000
]
buckets
=
[
0
,
1
,
5
,
10
,
20
,
50
,
100
,
200
,
500
,
1000
,
2000
,
3000
]
::
Gitlab
::
Metrics
.
histogram
(
name
,
comment
,
labels
,
buckets
)
end
...
...
spec/lib/gitlab/ci/pipeline/chain/limit/deployments_spec.rb
View file @
ae2b035e
...
...
@@ -85,7 +85,7 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Chain::Limit::Deployments do
end
it
'logs the error'
do
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:
track
_exception
).
with
(
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:
log
_exception
).
with
(
instance_of
(
Gitlab
::
Ci
::
Limit
::
LimitExceededError
),
project_id:
project
.
id
,
plan:
namespace
.
actual_plan_name
)
...
...
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