Commit 9c61bf03 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'remove-feature-flag-fix-flag' into 'master'

Remove feature_flags_cache_stale_read_fix flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!59398
parents 45bd7c92 47fabbaf
---
title: Fix rare race condition in GitLab-internal feature flags with database load
balancing enabled
merge_request:
author:
type: fixed
---
name: feature_flags_cache_stale_read_fix
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57819
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/325452
milestone: '13.11'
type: development
group:
default_enabled: false
......@@ -5,24 +5,18 @@
class Feature
class ActiveSupportCacheStoreAdapter < Flipper::Adapters::ActiveSupportCacheStore
def enable(feature, gate, thing)
return super unless Feature.enabled?(:feature_flags_cache_stale_read_fix, default_enabled: :yaml)
result = @adapter.enable(feature, gate, thing)
@cache.write(key_for(feature.key), @adapter.get(feature), @write_options)
result
end
def disable(feature, gate, thing)
return super unless Feature.enabled?(:feature_flags_cache_stale_read_fix, default_enabled: :yaml)
result = @adapter.disable(feature, gate, thing)
@cache.write(key_for(feature.key), @adapter.get(feature), @write_options)
result
end
def remove(feature)
return super unless Feature.enabled?(:feature_flags_cache_stale_read_fix, default_enabled: :yaml)
result = @adapter.remove(feature)
@cache.delete(FeaturesKey)
@cache.write(key_for(feature.key), {}, @write_options)
......
......@@ -507,16 +507,7 @@ RSpec.describe Feature, stub_feature_flags: false do
end
end
[true, false].each do |enabled|
context "with feature_flags_cache_stale_read_fix #{enabled ? 'enabled' : 'disabled'}" do # rubocop:disable RSpec/EmptyExampleGroup
# Without this environment variable enabled we want the specs to fail.
method = enabled ? :it : :pending
before do
stub_feature_flags(feature_flags_cache_stale_read_fix: enabled)
end
send(method, 'gives the correct value when enabling for an additional actor') do
it 'gives the correct value when enabling for an additional actor' do
described_class.enable(:enabled_feature_flag, actor)
initial_gate_values = active_record_adapter.get(described_class.get(:enabled_feature_flag))
......@@ -535,7 +526,7 @@ RSpec.describe Feature, stub_feature_flags: false do
expect(described_class.enabled?(:enabled_feature_flag)).to be(false)
end
send(method, 'gives the correct value when enabling for percentage of time') do
it 'gives the correct value when enabling for percentage of time' do
described_class.enable_percentage_of_time(:enabled_feature_flag, 10)
initial_gate_values = active_record_adapter.get(described_class.get(:enabled_feature_flag))
......@@ -550,7 +541,7 @@ RSpec.describe Feature, stub_feature_flags: false do
expect(described_class.get(:enabled_feature_flag).gate_values.percentage_of_time).to eq(50)
end
send(method, 'gives the correct value when disabling the flag') do
it 'gives the correct value when disabling the flag' do
described_class.enable(:enabled_feature_flag, actor)
described_class.enable(:enabled_feature_flag, another_actor)
initial_gate_values = active_record_adapter.get(described_class.get(:enabled_feature_flag))
......@@ -570,7 +561,7 @@ RSpec.describe Feature, stub_feature_flags: false do
expect(described_class.enabled?(:enabled_feature_flag)).to be(false)
end
send(method, 'gives the correct value when deleting the flag') do
it 'gives the correct value when deleting the flag' do
described_class.enable(:enabled_feature_flag, actor)
initial_gate_values = active_record_adapter.get(described_class.get(:enabled_feature_flag))
......@@ -587,8 +578,6 @@ RSpec.describe Feature, stub_feature_flags: false do
expect(described_class.enabled?(:enabled_feature_flag)).to be(false)
end
end
end
end
describe Feature::Target do
describe '#targets' do
......
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