Commit d2e17c0c authored by David Kim's avatar David Kim

Merge branch 'remove-ff-idempotent-ci-minutes-consumption' into 'master'

Remove feature flag idempotent_ci_minutes_consumption

See merge request gitlab-org/gitlab!71840
parents 97c74f9f f82d4f06
......@@ -7,7 +7,7 @@ module Ci
IDEMPOTENCY_CACHE_TTL = 12.hours
def initialize(project_id, namespace_id, build_id = nil)
def initialize(project_id, namespace_id, build_id)
@project_id = project_id
@namespace_id = namespace_id
@build_id = build_id
......@@ -19,14 +19,7 @@ module Ci
def execute(consumption)
legacy_track_usage_of_monthly_minutes(consumption)
# TODO: fix this condition after the next deployment when `build_id`
# is made a mandatory argument.
# https://gitlab.com/gitlab-org/gitlab/-/issues/331785
if @build_id && idempotent_consumption_enabled?
ensure_idempotency { track_usage_of_monthly_minutes(consumption) }
else
track_usage_of_monthly_minutes(consumption)
end
ensure_idempotency { track_usage_of_monthly_minutes(consumption) }
send_minutes_email_notification
end
......@@ -134,15 +127,6 @@ module Ci
redis.exists(idempotency_cache_key)
end
end
# When running this worker the project might have been deleted.
# In this case we consider the feature flag disabled for backward
# compatibility.
def idempotent_consumption_enabled?
return false unless @project
Feature.enabled?(:idempotent_ci_minutes_consumption, @project, default_enabled: :yaml)
end
end
end
end
---
name: idempotent_ci_minutes_consumption
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69994
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/340517
milestone: '14.4'
type: development
group: group::pipeline execution
default_enabled: false
......@@ -143,10 +143,8 @@ RSpec.describe Ci::Minutes::UpdateProjectAndNamespaceUsageService do
it 'does not create nested transactions', :delete do
expect(ApplicationRecord.connection.transaction_open?).to be false
service = described_class.new(project.id, namespace.id)
queries = ActiveRecord::QueryRecorder.new do
service
subject
end
savepoints = queries.occurrences.keys.flatten.select do |query|
......@@ -194,20 +192,6 @@ RSpec.describe Ci::Minutes::UpdateProjectAndNamespaceUsageService do
subject
end
context 'when feature flag idempotent_ci_minutes_consumption is disabled' do
before do
stub_feature_flags(idempotent_ci_minutes_consumption: false)
end
it_behaves_like 'updates monthly consumption'
end
context 'when build_id is not provided as parameter' do
let(:service) { described_class.new(project.id, namespace.id) }
it_behaves_like 'updates monthly consumption' # not idempotent / temporary backwards compatibility
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