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
98e1eca7
Commit
98e1eca7
authored
Aug 16, 2021
by
Maxime Orefice
Committed by
Grzegorz Bizon
Aug 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fetch pending builds with denormalized ci minutes
parent
b62b5f97
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
101 additions
and
0 deletions
+101
-0
app/services/ci/queue/builds_table_strategy.rb
app/services/ci/queue/builds_table_strategy.rb
+4
-0
app/services/ci/queue/pending_builds_strategy.rb
app/services/ci/queue/pending_builds_strategy.rb
+6
-0
config/feature_flags/development/ci_queueing_denormalize_ci_minutes_information.yml
...opment/ci_queueing_denormalize_ci_minutes_information.yml
+8
-0
ee/app/models/ee/ci/pending_build.rb
ee/app/models/ee/ci/pending_build.rb
+4
-0
ee/app/services/ee/ci/queue/build_queue_service.rb
ee/app/services/ee/ci/queue/build_queue_service.rb
+8
-0
ee/app/services/ee/ci/queue/pending_builds_strategy.rb
ee/app/services/ee/ci/queue/pending_builds_strategy.rb
+15
-0
ee/spec/models/ee/ci/pending_build_spec.rb
ee/spec/models/ee/ci/pending_build_spec.rb
+22
-0
ee/spec/services/ci/register_job_service_spec.rb
ee/spec/services/ci/register_job_service_spec.rb
+34
-0
No files found.
app/services/ci/queue/builds_table_strategy.rb
View file @
98e1eca7
...
...
@@ -57,6 +57,10 @@ module Ci
false
end
def
use_denormalized_minutes_data?
false
end
private
def
running_builds_for_shared_runners
...
...
app/services/ci/queue/pending_builds_strategy.rb
View file @
98e1eca7
...
...
@@ -40,6 +40,10 @@ module Ci
::
Feature
.
enabled?
(
:ci_queueing_denormalize_shared_runners_information
,
runner
,
type: :development
,
default_enabled: :yaml
)
end
def
use_denormalized_minutes_data?
::
Feature
.
enabled?
(
:ci_queueing_denormalize_ci_minutes_information
,
runner
,
type: :development
,
default_enabled: :yaml
)
end
private
def
builds_available_for_shared_runners
...
...
@@ -83,3 +87,5 @@ module Ci
end
end
end
Ci
::
Queue
::
PendingBuildsStrategy
.
prepend_mod_with
(
'Ci::Queue::PendingBuildsStrategy'
)
config/feature_flags/development/ci_queueing_denormalize_ci_minutes_information.yml
0 → 100644
View file @
98e1eca7
---
name
:
ci_queueing_denormalize_ci_minutes_information
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66962
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/338290
milestone
:
'
14.2'
type
:
development
group
:
'
group::pipeline
execution'
default_enabled
:
false
ee/app/models/ee/ci/pending_build.rb
View file @
98e1eca7
...
...
@@ -5,6 +5,10 @@ module EE
module
PendingBuild
extend
ActiveSupport
::
Concern
prepended
do
scope
:with_ci_minutes_available
,
->
{
where
(
minutes_exceeded:
false
)
}
end
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
...
...
ee/app/services/ee/ci/queue/build_queue_service.rb
View file @
98e1eca7
...
...
@@ -19,6 +19,14 @@ module EE
# rubocop: disable CodeReuse/ActiveRecord
def
enforce_minutes_based_on_cost_factors
(
relation
)
if
strategy
.
use_denormalized_minutes_data?
strategy
.
enforce_minutes_quota
(
relation
)
else
enforce_minutes_using_legacy_data
(
relation
)
end
end
def
enforce_minutes_using_legacy_data
(
relation
)
if
strategy
.
use_denormalized_shared_runners_data?
# If shared runners information is denormalized then the query does not include the join
# with `projects` anymore, so we need to add it until we use denormalized ci minutes
...
...
ee/app/services/ee/ci/queue/pending_builds_strategy.rb
0 → 100644
View file @
98e1eca7
# frozen_string_literal: true
module
EE
module
Ci
module
Queue
module
PendingBuildsStrategy
extend
ActiveSupport
::
Concern
def
enforce_minutes_quota
(
relation
)
relation
.
with_ci_minutes_available
end
end
end
end
end
ee/spec/models/ee/ci/pending_build_spec.rb
View file @
98e1eca7
...
...
@@ -8,6 +8,28 @@ RSpec.describe Ci::PendingBuild do
let
(
:build
)
{
create
(
:ci_build
,
:created
,
pipeline:
pipeline
,
project:
project
)
}
describe
'scopes'
do
describe
'.with_ci_minutes_available'
do
subject
(
:pending_builds
)
{
described_class
.
with_ci_minutes_available
}
context
'when pending builds does not have ci minutes available'
do
let!
(
:pending_build
)
{
create
(
:ci_pending_build
,
minutes_exceeded:
true
)
}
it
'returns an empty collection of pending builds'
do
expect
(
pending_builds
).
to
be_empty
end
end
context
'when pending builds have ci minutes available'
do
let!
(
:pending_build
)
{
create
(
:ci_pending_build
,
minutes_exceeded:
false
)
}
it
'returns matching pending builds'
do
expect
(
pending_builds
).
to
contain_exactly
(
pending_build
)
end
end
end
end
describe
'.upsert_from_build!'
do
shared_examples
'ci minutes not available'
do
it
'sets minutes_exceeded to true'
do
...
...
ee/spec/services/ci/register_job_service_spec.rb
View file @
98e1eca7
...
...
@@ -41,12 +41,30 @@ RSpec.describe Ci::RegisterJobService, '#execute' do
is_expected
.
to
be_kind_of
(
Ci
::
Build
)
end
context
'with ci_queueing_denormalize_ci_minutes_information enabled'
do
before
do
stub_feature_flags
(
ci_queueing_denormalize_ci_minutes_information:
true
)
end
it
{
is_expected
.
to
be_kind_of
(
Ci
::
Build
)
}
end
context
'with ci_queueing_denormalize_ci_minutes_information disabled'
do
before
do
stub_feature_flags
(
ci_queueing_denormalize_ci_minutes_information:
false
)
end
it
{
is_expected
.
to
be_kind_of
(
Ci
::
Build
)
}
end
end
shared_examples
'does not return a build'
do
|
runners_minutes_used
|
before
do
project
.
namespace
.
create_namespace_statistics
(
shared_runners_seconds:
runners_minutes_used
*
60
)
pending_build
.
reload
pending_build
.
create_queuing_entry!
end
context
'with traversal_ids enabled'
do
...
...
@@ -71,6 +89,22 @@ RSpec.describe Ci::RegisterJobService, '#execute' do
is_expected
.
to
be_kind_of
(
Ci
::
Build
)
end
context
'with ci_queueing_denormalize_ci_minutes_information enabled'
do
before
do
stub_feature_flags
(
ci_queueing_denormalize_ci_minutes_information:
true
)
end
it
{
is_expected
.
to
be_nil
}
end
context
'with ci_queueing_denormalize_ci_minutes_information disabled'
do
before
do
stub_feature_flags
(
ci_queueing_denormalize_ci_minutes_information:
false
)
end
it
{
is_expected
.
to
be_nil
}
end
end
context
'when limit set at global level'
do
...
...
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