Commit 9ccc7c29 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Decouple writing pending builds from FFs class and actors

parent 910bbbfa
...@@ -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)
......
...@@ -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
...@@ -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)
......
--- ---
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
......
...@@ -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
......
...@@ -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
......
...@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment