Commit 20dbc7cf authored by Vladimir Shushlin's avatar Vladimir Shushlin

Guard pages legacy storage lease by feature flag

parent 7431644b
......@@ -8,6 +8,15 @@ module Pages
LEASE_TIMEOUT = 1.hour
# override method from exclusive lease guard to guard it by feature flag
# TODO: just remove this method after testing this in production
# https://gitlab.com/gitlab-org/gitlab/-/issues/282464
def try_obtain_lease
return yield unless Feature.enabled?(:pages_use_legacy_storage_lease, project)
super
end
def lease_key
"pages_legacy_storage:#{project.id}"
end
......
---
name: pages_use_legacy_storage_lease
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48349
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/282464
milestone: '13.7'
type: development
group: group::release
default_enabled: false
......@@ -30,9 +30,9 @@ RSpec.describe ::Pages::LegacyStorageLease do
let(:service) { implementation.new(project) }
it 'allows method to be executed' do
expect(service).to receive :execute_unsafe
expect(service).to receive(:execute_unsafe).and_call_original
service.execute
expect(service.execute).to eq(true)
end
context 'when another service holds the lease for the same project' do
......@@ -47,6 +47,14 @@ RSpec.describe ::Pages::LegacyStorageLease do
expect(service.execute).to eq(nil)
end
it 'runs guarded method if feature flag is disabled' do
stub_feature_flags(pages_use_legacy_storage_lease: false)
expect(service).to receive(:execute_unsafe).and_call_original
expect(service.execute).to eq(true)
end
end
context 'when another service holds the lease for the different project' 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