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
9ccc7c29
Commit
9ccc7c29
authored
Nov 30, 2021
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decouple writing pending builds from FFs class and actors
parent
910bbbfa
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
15 deletions
+15
-15
app/models/ci/pending_build.rb
app/models/ci/pending_build.rb
+5
-1
app/services/ci/update_build_queue_service.rb
app/services/ci/update_build_queue_service.rb
+6
-6
app/services/ci/update_pending_build_service.rb
app/services/ci/update_pending_build_service.rb
+1
-1
config/feature_flags/development/ci_pending_builds_maintain_denormalized_data.yml
...elopment/ci_pending_builds_maintain_denormalized_data.yml
+1
-1
ee/app/models/ee/ci/pending_build.rb
ee/app/models/ee/ci/pending_build.rb
+1
-1
ee/app/services/ci/minutes/refresh_cached_data_service.rb
ee/app/services/ci/minutes/refresh_cached_data_service.rb
+1
-1
lib/gitlab/ci/features.rb
lib/gitlab/ci/features.rb
+0
-4
No files found.
app/models/ci/pending_build.rb
View file @
9ccc7c29
...
@@ -30,6 +30,10 @@ module Ci
...
@@ -30,6 +30,10 @@ module Ci
self
.
upsert
(
entry
.
attributes
.
compact
,
returning:
%w[build_id]
,
unique_by: :build_id
)
self
.
upsert
(
entry
.
attributes
.
compact
,
returning:
%w[build_id]
,
unique_by: :build_id
)
end
end
def
maintain_denormalized_data?
::
Feature
.
enabled?
(
:ci_pending_builds_maintain_denormalized_data
,
default_enabled: :yaml
)
end
private
private
def
args_from_build
(
build
)
def
args_from_build
(
build
)
...
@@ -42,7 +46,7 @@ module Ci
...
@@ -42,7 +46,7 @@ module Ci
namespace:
project
.
namespace
namespace:
project
.
namespace
}
}
if
::
Gitlab
::
Ci
::
Features
.
pending_builds_maintain_denormalized_data?
(
project
)
if
maintain_denormalized_data?
args
.
store
(
:tag_ids
,
build
.
tags_ids
)
args
.
store
(
:tag_ids
,
build
.
tags_ids
)
args
.
store
(
:instance_runners_enabled
,
shared_runners_enabled?
(
project
))
args
.
store
(
:instance_runners_enabled
,
shared_runners_enabled?
(
project
))
args
.
store
(
:namespace_traversal_ids
,
project
.
namespace
.
traversal_ids
)
if
group_runners_enabled?
(
project
)
args
.
store
(
:namespace_traversal_ids
,
project
.
namespace
.
traversal_ids
)
if
group_runners_enabled?
(
project
)
...
...
app/services/ci/update_build_queue_service.rb
View file @
9ccc7c29
...
@@ -14,7 +14,7 @@ module Ci
...
@@ -14,7 +14,7 @@ module Ci
# Add a build to the pending builds queue
# Add a build to the pending builds queue
#
#
def
push
(
build
,
transition
)
def
push
(
build
,
transition
)
return
unless
maintain_pending_builds_queue?
(
build
)
return
unless
maintain_pending_builds_queue?
raise
InvalidQueueTransition
unless
transition
.
to
==
'pending'
raise
InvalidQueueTransition
unless
transition
.
to
==
'pending'
...
@@ -33,7 +33,7 @@ module Ci
...
@@ -33,7 +33,7 @@ module Ci
# Remove a build from the pending builds queue
# Remove a build from the pending builds queue
#
#
def
pop
(
build
,
transition
)
def
pop
(
build
,
transition
)
return
unless
maintain_pending_builds_queue?
(
build
)
return
unless
maintain_pending_builds_queue?
raise
InvalidQueueTransition
unless
transition
.
from
==
'pending'
raise
InvalidQueueTransition
unless
transition
.
from
==
'pending'
...
@@ -52,7 +52,7 @@ module Ci
...
@@ -52,7 +52,7 @@ module Ci
# Add shared runner build tracking entry (used for queuing).
# Add shared runner build tracking entry (used for queuing).
#
#
def
track
(
build
,
transition
)
def
track
(
build
,
transition
)
return
unless
maintain_pending_builds_queue?
(
build
)
return
unless
maintain_pending_builds_queue?
return
unless
build
.
shared_runner_build?
return
unless
build
.
shared_runner_build?
raise
InvalidQueueTransition
unless
transition
.
to
==
'running'
raise
InvalidQueueTransition
unless
transition
.
to
==
'running'
...
@@ -73,7 +73,7 @@ module Ci
...
@@ -73,7 +73,7 @@ module Ci
# queuing).
# queuing).
#
#
def
untrack
(
build
,
transition
)
def
untrack
(
build
,
transition
)
return
unless
maintain_pending_builds_queue?
(
build
)
return
unless
maintain_pending_builds_queue?
return
unless
build
.
shared_runner_build?
return
unless
build
.
shared_runner_build?
raise
InvalidQueueTransition
unless
transition
.
from
==
'running'
raise
InvalidQueueTransition
unless
transition
.
from
==
'running'
...
@@ -113,8 +113,8 @@ module Ci
...
@@ -113,8 +113,8 @@ module Ci
end
end
end
end
def
maintain_pending_builds_queue?
(
build
)
def
maintain_pending_builds_queue?
::
Gitlab
::
Ci
::
Features
.
pending_builds_maintain_denormalized_data?
(
build
.
project
)
::
Ci
::
PendingBuild
.
maintain_denormalized_data?
end
end
end
end
end
end
app/services/ci/update_pending_build_service.rb
View file @
9ccc7c29
...
@@ -15,7 +15,7 @@ module Ci
...
@@ -15,7 +15,7 @@ module Ci
end
end
def
execute
def
execute
return
unless
::
Gitlab
::
Ci
::
Features
.
pending_builds_maintain_denormalized_data?
(
@model
)
return
unless
::
Ci
::
PendingBuild
.
maintain_denormalized_data?
@model
.
pending_builds
.
each_batch
do
|
relation
|
@model
.
pending_builds
.
each_batch
do
|
relation
|
relation
.
update_all
(
@update_params
)
relation
.
update_all
(
@update_params
)
...
...
config/feature_flags/development/ci_pending_builds_maintain_denormalized_data.yml
View file @
9ccc7c29
---
---
name
:
ci_pending_builds_maintain_denormalized_data
name
:
ci_pending_builds_maintain_denormalized_data
introduced_by_url
:
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75425
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/332951
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/332951
milestone
:
'
14.6'
milestone
:
'
14.6'
type
:
development
type
:
development
...
...
ee/app/models/ee/ci/pending_build.rb
View file @
9ccc7c29
...
@@ -14,7 +14,7 @@ module EE
...
@@ -14,7 +14,7 @@ module EE
override
:args_from_build
override
:args_from_build
def
args_from_build
(
build
)
def
args_from_build
(
build
)
return
super
unless
::
Gitlab
::
Ci
::
Features
.
pending_builds_maintain_denormalized_data?
(
build
&
.
project
&
.
root_namespace
)
return
super
unless
maintain_denormalized_data?
super
.
merge
(
minutes_exceeded:
minutes_exceeded?
(
build
.
project
))
super
.
merge
(
minutes_exceeded:
minutes_exceeded?
(
build
.
project
))
end
end
...
...
ee/app/services/ci/minutes/refresh_cached_data_service.rb
View file @
9ccc7c29
...
@@ -27,7 +27,7 @@ module Ci
...
@@ -27,7 +27,7 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
update_pending_builds!
def
update_pending_builds!
return
unless
::
Gitlab
::
Ci
::
Features
.
pending_builds_maintain_denormalized_data?
(
@root_namespace
)
return
unless
::
Ci
::
PendingBuild
.
maintain_denormalized_data?
minutes_exceeded
=
@root_namespace
.
ci_minutes_quota
.
minutes_used_up?
minutes_exceeded
=
@root_namespace
.
ci_minutes_quota
.
minutes_used_up?
all_namespace_ids
=
@root_namespace
.
self_and_descendant_ids
.
ids
all_namespace_ids
=
@root_namespace
.
self_and_descendant_ids
.
ids
...
...
lib/gitlab/ci/features.rb
View file @
9ccc7c29
...
@@ -25,10 +25,6 @@ module Gitlab
...
@@ -25,10 +25,6 @@ module Gitlab
def
self
.
gldropdown_tags_enabled?
def
self
.
gldropdown_tags_enabled?
::
Feature
.
enabled?
(
:gldropdown_tags
,
default_enabled: :yaml
)
::
Feature
.
enabled?
(
:gldropdown_tags
,
default_enabled: :yaml
)
end
end
def
self
.
pending_builds_maintain_denormalized_data?
(
actor
)
::
Feature
.
enabled?
(
:ci_pending_builds_maintain_denormalized_data
,
actor
,
default_enabled: :yaml
)
end
end
end
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