Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
67e0c38c
Commit
67e0c38c
authored
Dec 07, 2020
by
Aakriti Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-factor check for maintenance mode
parent
c69f85f2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
20 deletions
+30
-20
ee/app/helpers/ee/application_helper.rb
ee/app/helpers/ee/application_helper.rb
+1
-7
ee/lib/ee/gitlab/git_access.rb
ee/lib/ee/gitlab/git_access.rb
+1
-5
ee/lib/ee/gitlab/middleware/read_only/controller.rb
ee/lib/ee/gitlab/middleware/read_only/controller.rb
+2
-8
lib/gitlab.rb
lib/gitlab.rb
+6
-0
spec/lib/gitlab_spec.rb
spec/lib/gitlab_spec.rb
+20
-0
No files found.
ee/app/helpers/ee/application_helper.rb
View file @
67e0c38c
...
...
@@ -13,7 +13,7 @@ module EE
def
read_only_message
message
=
::
Gitlab
::
Geo
.
secondary?
?
geo_secondary_read_only_message
:
super
return
message
unless
maintenance_mode?
return
message
unless
::
Gitlab
.
maintenance_mode?
return
maintenance_mode_message
.
concat
(
message
)
if
message
maintenance_mode_message
...
...
@@ -156,11 +156,5 @@ module EE
next_unprocessed_event
.
created_at
<
EVENT_LAG_SHOW_THRESHOLD
.
ago
end
end
def
maintenance_mode?
return
unless
::
Feature
.
enabled?
(
:maintenance_mode
)
::
Gitlab
::
CurrentSettings
.
maintenance_mode
end
end
end
ee/lib/ee/gitlab/git_access.rb
View file @
67e0c38c
...
...
@@ -96,15 +96,11 @@ module EE
def
check_maintenance_mode!
(
cmd
)
return
unless
cmd
==
'git-receive-pack'
return
unless
maintenance_mode?
return
unless
::
Gitlab
.
maintenance_mode?
raise
::
Gitlab
::
GitAccess
::
ForbiddenError
,
'Git push is not allowed because this GitLab instance is currently in (read-only) maintenance mode.'
end
def
maintenance_mode?
::
Gitlab
::
CurrentSettings
.
current_application_settings
.
maintenance_mode
end
def
can_access_without_new_smartcard_login?
return
true
unless
user
...
...
ee/lib/ee/gitlab/middleware/read_only/controller.rb
View file @
67e0c38c
...
...
@@ -36,7 +36,7 @@ module EE
allowed
=
super
||
geo_node_update_route?
||
geo_api_route?
return
true
if
allowed
return
false
if
maintenance_mode?
return
false
if
::
Gitlab
.
maintenance_mode?
return
false
unless
::
Gitlab
::
Geo
.
secondary?
git_write_routes
...
...
@@ -90,13 +90,7 @@ module EE
override
:read_only?
def
read_only?
maintenance_mode?
||
super
end
def
maintenance_mode?
return
unless
::
Feature
.
enabled?
(
:maintenance_mode
)
::
Gitlab
::
CurrentSettings
.
maintenance_mode
::
Gitlab
.
maintenance_mode?
||
super
end
end
end
...
...
lib/gitlab.rb
View file @
67e0c38c
...
...
@@ -115,4 +115,10 @@ module Gitlab
'web'
end
def
self
.
maintenance_mode?
return
false
unless
::
Feature
.
enabled?
(
:maintenance_mode
)
::
Gitlab
::
CurrentSettings
.
maintenance_mode
end
end
spec/lib/gitlab_spec.rb
View file @
67e0c38c
...
...
@@ -329,4 +329,24 @@ RSpec.describe Gitlab do
expect
(
described_class
.
http_proxy_env?
).
to
eq
(
false
)
end
end
describe
'.maintenance_mode?'
do
it
'returns true when maintenance mode is enabled'
do
stub_application_setting
(
maintenance_mode:
true
)
expect
(
described_class
.
maintenance_mode?
).
to
eq
(
true
)
end
it
'returns false when maintenance mode is disabled'
do
stub_application_setting
(
maintenance_mode:
false
)
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
)
expect
(
described_class
.
maintenance_mode?
).
to
eq
(
false
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment