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
self.upsert(entry.attributes.compact, returning: %w[build_id], unique_by: :build_id)
end
def maintain_denormalized_data?
::Feature.enabled?(:ci_pending_builds_maintain_denormalized_data, default_enabled: :yaml)
end
private
def args_from_build(build)
......@@ -42,7 +46,7 @@ module Ci
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(:instance_runners_enabled, shared_runners_enabled?(project))
args.store(:namespace_traversal_ids, project.namespace.traversal_ids) if group_runners_enabled?(project)
......
......@@ -14,7 +14,7 @@ module Ci
# Add a build to the pending builds queue
#
def push(build, transition)
return unless maintain_pending_builds_queue?(build)
return unless maintain_pending_builds_queue?
raise InvalidQueueTransition unless transition.to == 'pending'
......@@ -33,7 +33,7 @@ module Ci
# Remove a build from the pending builds queue
#
def pop(build, transition)
return unless maintain_pending_builds_queue?(build)
return unless maintain_pending_builds_queue?
raise InvalidQueueTransition unless transition.from == 'pending'
......@@ -52,7 +52,7 @@ module Ci
# Add shared runner build tracking entry (used for queuing).
#
def track(build, transition)
return unless maintain_pending_builds_queue?(build)
return unless maintain_pending_builds_queue?
return unless build.shared_runner_build?
raise InvalidQueueTransition unless transition.to == 'running'
......@@ -73,7 +73,7 @@ module Ci
# queuing).
#
def untrack(build, transition)
return unless maintain_pending_builds_queue?(build)
return unless maintain_pending_builds_queue?
return unless build.shared_runner_build?
raise InvalidQueueTransition unless transition.from == 'running'
......@@ -113,8 +113,8 @@ module Ci
end
end
def maintain_pending_builds_queue?(build)
::Gitlab::Ci::Features.pending_builds_maintain_denormalized_data?(build.project)
def maintain_pending_builds_queue?
::Ci::PendingBuild.maintain_denormalized_data?
end
end
end
......@@ -15,7 +15,7 @@ module Ci
end
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|
relation.update_all(@update_params)
......
---
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
milestone: '14.6'
type: development
......
......@@ -14,7 +14,7 @@ module EE
override :args_from_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))
end
......
......@@ -27,7 +27,7 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord
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?
all_namespace_ids = @root_namespace.self_and_descendant_ids.ids
......
......@@ -25,10 +25,6 @@ module Gitlab
def self.gldropdown_tags_enabled?
::Feature.enabled?(:gldropdown_tags, default_enabled: :yaml)
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
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