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
ecae79c3
Commit
ecae79c3
authored
Sep 28, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement pipeline size limit class
parent
f645ce7a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
0 deletions
+128
-0
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+4
-0
ee/lib/ee/gitlab/ci/pipeline/quota/size.rb
ee/lib/ee/gitlab/ci/pipeline/quota/size.rb
+41
-0
lib/gitlab/ci/stage/seed.rb
lib/gitlab/ci/stage/seed.rb
+2
-0
spec/ee/spec/lib/gitlab/ci/pipeline/quota/size_spec.rb
spec/ee/spec/lib/gitlab/ci/pipeline/quota/size_spec.rb
+81
-0
No files found.
app/models/ci/pipeline.rb
View file @
ecae79c3
...
...
@@ -325,6 +325,10 @@ module Ci
@stage_seeds
||=
config_processor
.
stage_seeds
(
self
)
end
def
seeds_size
@seeds_size
||=
stage_seeds
.
sum
(
&
:size
)
end
def
has_kubernetes_active?
project
.
kubernetes_service
&
.
active?
end
...
...
ee/lib/ee/gitlab/ci/pipeline/quota/size.rb
0 → 100644
View file @
ecae79c3
module
EE
module
Gitlab
module
Ci
module
Pipeline
module
Quota
class
Size
<
Ci
::
Limit
include
ActionView
::
Helpers
::
TextHelper
def
initialize
(
namespace
,
pipeline
)
@namespace
=
namespace
@pipeline
=
pipeline
end
def
enabled?
@namespace
.
max_pipeline_size
>
0
end
def
exceeded?
return
false
unless
enabled?
excessive_seeds_count
>
0
end
def
message
return
unless
exceeded?
'Pipeline size limit exceeded by '
\
"
#{
pluralize
(
excessive_seeds_count
,
'job'
)
}
!"
end
private
def
excessive_seeds_count
@excessive
||=
@pipeline
.
seeds_size
-
@namespace
.
max_pipeline_size
end
end
end
end
end
end
end
lib/gitlab/ci/stage/seed.rb
View file @
ecae79c3
...
...
@@ -3,7 +3,9 @@ module Gitlab
module
Stage
class
Seed
attr_reader
:pipeline
delegate
:project
,
to: :pipeline
delegate
:size
,
to: :@jobs
def
initialize
(
pipeline
,
stage
,
jobs
)
@pipeline
=
pipeline
...
...
spec/ee/spec/lib/gitlab/ci/pipeline/quota/size_spec.rb
0 → 100644
View file @
ecae79c3
require
'spec_helper'
describe
EE
::
Gitlab
::
Ci
::
Pipeline
::
Quota
::
Size
do
set
(
:namespace
)
{
create
(
:namespace
,
plan:
EE
::
Namespace
::
GOLD_PLAN
)
}
set
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
let
(
:pipeline
)
{
build_stubbed
(
:ci_pipeline
,
project:
project
)
}
let
(
:limit
)
{
described_class
.
new
(
namespace
,
pipeline
)
}
shared_context
'pipeline size limit exceeded'
do
let
(
:pipeline
)
do
config
=
{
rspec:
{
script:
'rspec'
},
spinach:
{
script:
'spinach'
}
}
build
(
:ci_pipeline
,
project:
project
,
config:
config
)
end
before
do
namespace
.
plan
.
update_column
(
:pipeline_size_limit
,
1
)
end
end
shared_context
'pipeline size limit not exceeded'
do
let
(
:pipeline
)
{
build
(
:ci_pipeline_with_one_job
,
project:
project
)
}
before
do
namespace
.
plan
.
update_column
(
:pipeline_size_limit
,
2
)
end
end
describe
'#enabled?'
do
context
'when limit is enabled in plan'
do
before
do
namespace
.
plan
.
update_column
(
:pipeline_size_limit
,
10
)
end
it
'is enabled'
do
expect
(
limit
).
to
be_enabled
end
end
context
'when limit is not enabled'
do
before
do
namespace
.
plan
.
update_column
(
:pipeline_size_limit
,
0
)
end
it
'is not enabled'
do
expect
(
limit
).
not_to
be_enabled
end
end
end
describe
'#exceeded?'
do
context
'when limit is exceeded'
do
include_context
'pipeline size limit exceeded'
it
'is exceeded'
do
expect
(
limit
).
to
be_exceeded
end
end
context
'when limit is not exceeded'
do
include_context
'pipeline size limit not exceeded'
it
'is not exceeded'
do
expect
(
limit
).
not_to
be_exceeded
end
end
end
describe
'#message'
do
context
'when limit is exceeded'
do
include_context
'pipeline size limit exceeded'
it
'returns infor about pipeline size limit exceeded'
do
expect
(
limit
.
message
)
.
to
eq
"Pipeline size limit exceeded by 1 job!"
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