Skip to content
Snippets Groups Projects
Commit db39efe2 authored by Peter Leitzen's avatar Peter Leitzen Committed by Mayra Cabrera
Browse files

Merge branch 'ag-check-if-maintenance-mode-setting-is-present' into 'master'

Check if maintenance_mode setting is available

See merge request gitlab-org/gitlab!54439
parent 542b6ded
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -123,6 +123,16 @@ def self.process_name
def self.maintenance_mode?
return false unless ::Gitlab::CurrentSettings.current_application_settings?
 
# `maintenance_mode` column was added to the `current_settings` table in 13.2
# When upgrading from < 13.2 to >=13.8 `maintenance_mode` will not be
# found in settings.
# `Gitlab::CurrentSettings#uncached_application_settings` in
# lib/gitlab/current_settings.rb is expected to handle such cases, and use
# the default value for the setting instead, but in this case, it doesn't,
# see https://gitlab.com/gitlab-org/gitlab/-/issues/321836
# As a work around, we check if the setting method is available
return false unless ::Gitlab::CurrentSettings.respond_to?(:maintenance_mode)
::Gitlab::CurrentSettings.maintenance_mode
end
end
Loading
Loading
@@ -363,8 +363,13 @@
expect(described_class.maintenance_mode?).to eq(false)
end
 
it 'returns false when maintenance mode feature flag is disabled' do
stub_feature_flags(maintenance_mode: false)
it 'returns false when maintenance mode column is not present' do
stub_maintenance_mode_setting(true)
allow(::Gitlab::CurrentSettings.current_application_settings)
.to receive(:respond_to?)
.with(:maintenance_mode, false)
.and_return(false)
 
expect(described_class.maintenance_mode?).to eq(false)
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment