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
09e84bec
Commit
09e84bec
authored
Jun 11, 2021
by
Furkan Ayhan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add daily_limit and pass it to frontend
parent
23884fb5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
4 deletions
+33
-4
app/models/ci/pipeline_schedule.rb
app/models/ci/pipeline_schedule.rb
+4
-0
app/services/ci/pipeline_schedules/calculate_next_run_service.rb
...vices/ci/pipeline_schedules/calculate_next_run_service.rb
+3
-3
app/views/projects/pipeline_schedules/_form.html.haml
app/views/projects/pipeline_schedules/_form.html.haml
+1
-1
spec/models/ci/pipeline_schedule_spec.rb
spec/models/ci/pipeline_schedule_spec.rb
+25
-0
No files found.
app/models/ci/pipeline_schedule.rb
View file @
09e84bec
...
...
@@ -63,6 +63,10 @@ module Ci
.
execute
(
self
,
fallback_method:
method
(
:calculate_next_run_at
))
end
def
daily_limit
project
.
actual_limits
.
limit_for
(
:ci_daily_pipeline_schedule_triggers
)
end
private
def
worker_cron_expression
...
...
app/services/ci/pipeline_schedules/calculate_next_run_service.rb
View file @
09e84bec
...
...
@@ -41,11 +41,11 @@ module Ci
def
plan_cron
strong_memoize
(
:plan_cron
)
do
daily_
scheduled_pipeline_limit
=
project
.
actual_limits
.
limit_for
(
:ci_daily_pipeline_schedule_triggers
)
daily_
limit
=
@schedule
.
daily_limit
next
unless
daily_
scheduled_pipeline_
limit
next
unless
daily_limit
every_x_minutes
=
(
1
.
day
.
in_minutes
/
daily_
scheduled_pipeline_
limit
).
to_i
every_x_minutes
=
(
1
.
day
.
in_minutes
/
daily_limit
).
to_i
Gitlab
::
Ci
::
CronParser
.
parse_natural
(
"every
#{
every_x_minutes
}
minutes"
,
Time
.
zone
.
name
)
end
...
...
app/views/projects/pipeline_schedules/_form.html.haml
View file @
09e84bec
...
...
@@ -7,7 +7,7 @@
.form-group.row
.col-md-9
=
f
.
label
:cron
,
_
(
'Interval Pattern'
),
class:
'label-bold'
#interval-pattern-input
{
data:
{
initial_interval:
@schedule
.
cron
}
}
#interval-pattern-input
{
data:
{
initial_interval:
@schedule
.
cron
,
daily_limit:
@schedule
.
daily_limit
}
}
.form-group.row
.col-md-9
=
f
.
label
:cron_timezone
,
_
(
'Cron Timezone'
),
class:
'label-bold'
...
...
spec/models/ci/pipeline_schedule_spec.rb
View file @
09e84bec
...
...
@@ -122,6 +122,9 @@ RSpec.describe Ci::PipelineSchedule do
'*/5 * * * *'
|
'0 * * * *'
|
(
1
.
day
.
in_minutes
/
10
).
to_i
|
false
|
Time
.
zone
.
local
(
2021
,
5
,
27
,
11
,
0
)
|
Time
.
zone
.
local
(
2021
,
5
,
27
,
12
,
5
)
'*/5 * * * *'
|
'0 * * * *'
|
(
1
.
day
.
in_minutes
/
1
.
hour
.
in_minutes
).
to_i
|
true
|
Time
.
zone
.
local
(
2021
,
5
,
27
,
11
,
0
)
|
Time
.
zone
.
local
(
2021
,
5
,
27
,
12
,
0
)
'*/5 * * * *'
|
'0 * * * *'
|
(
1
.
day
.
in_minutes
/
2
.
hours
.
in_minutes
).
to_i
|
true
|
Time
.
zone
.
local
(
2021
,
5
,
27
,
11
,
0
)
|
Time
.
zone
.
local
(
2021
,
5
,
27
,
12
,
5
)
'*/5 * * * *'
|
'0 1 * * *'
|
(
1
.
day
.
in_minutes
/
1
.
hour
.
in_minutes
).
to_i
|
true
|
Time
.
zone
.
local
(
2021
,
5
,
27
,
1
,
0
)
|
Time
.
zone
.
local
(
2021
,
5
,
28
,
1
,
0
)
'*/5 * * * *'
|
'0 1 * * *'
|
(
1
.
day
.
in_minutes
/
1
.
hour
.
in_minutes
).
to_i
|
true
|
Time
.
zone
.
local
(
2021
,
5
,
27
,
1
,
0
)
|
Time
.
zone
.
local
(
2021
,
5
,
28
,
1
,
0
)
'*/5 * * * *'
|
'0 1 1 * *'
|
(
1
.
day
.
in_minutes
/
1
.
hour
.
in_minutes
).
to_i
|
true
|
Time
.
zone
.
local
(
2021
,
5
,
1
,
1
,
0
)
|
Time
.
zone
.
local
(
2021
,
6
,
1
,
1
,
0
)
end
with_them
do
...
...
@@ -198,4 +201,26 @@ RSpec.describe Ci::PipelineSchedule do
it
{
is_expected
.
to
contain_exactly
(
*
pipeline_schedule_variables
.
map
(
&
:to_runner_variable
))
}
end
describe
'#daily_limit'
do
let
(
:pipeline_schedule
)
{
build
(
:ci_pipeline_schedule
)
}
subject
(
:daily_limit
)
{
pipeline_schedule
.
daily_limit
}
context
'when there is no limit'
do
before
do
create
(
:plan_limits
,
:default_plan
,
ci_daily_pipeline_schedule_triggers:
0
)
end
it
{
is_expected
.
to
be_nil
}
end
context
'when there is a limit'
do
before
do
create
(
:plan_limits
,
:default_plan
,
ci_daily_pipeline_schedule_triggers:
144
)
end
it
{
is_expected
.
to
eq
(
144
)
}
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