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
23d9ea0a
Commit
23d9ea0a
authored
Mar 17, 2020
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Geo redirect/proxy messages into Gitlab::Geo
parent
3089df26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
18 deletions
+58
-18
ee/lib/ee/gitlab/geo_git_access.rb
ee/lib/ee/gitlab/geo_git_access.rb
+1
-18
ee/lib/gitlab/geo.rb
ee/lib/gitlab/geo.rb
+29
-0
ee/spec/lib/gitlab/geo_spec.rb
ee/spec/lib/gitlab/geo_spec.rb
+28
-0
No files found.
ee/lib/ee/gitlab/geo_git_access.rb
View file @
23d9ea0a
...
...
@@ -40,7 +40,7 @@ module EE
end
def
messages
messages
=
proxying_to_primary_message
messages
=
::
Gitlab
::
Geo
.
proxying_push_to_primary_message
(
primary_ssh_url_to_repo
).
split
(
"
\n
"
)
lag_message
=
current_replication_lag_message
return
messages
unless
lag_message
...
...
@@ -75,23 +75,6 @@ module EE
geo_primary_ssh_url_to_repo
(
project_or_wiki
)
end
def
proxying_to_primary_message
# This is formatted like this to fit into the console 'box', e.g.
#
# remote:
# remote: You're pushing to a Geo secondary! We'll help you by proxying this
# remote: request to the primary:
# remote:
# remote: ssh://<user>@<host>:<port>/<group>/<repo>.git
# remote:
<<~
STR
.
split
(
"
\n
"
)
You're pushing to a Geo secondary! We'll help you by proxying this
request to the primary:
#{
primary_ssh_url_to_repo
}
STR
end
def
current_replication_lag_message
return
if
::
Gitlab
::
Database
.
read_write?
||
current_replication_lag
.
zero?
...
...
ee/lib/gitlab/geo.rb
View file @
23d9ea0a
...
...
@@ -136,5 +136,34 @@ module Gitlab
Gitlab
::
CIDR
.
new
(
allowed_ips
).
match?
(
ip
)
end
def
self
.
proxying_push_to_primary_message
(
url
)
push_to_primary_message
(
url
,
'proxying'
)
end
def
self
.
redirecting_push_to_primary_message
(
url
)
push_to_primary_message
(
url
,
'redirecting'
)
end
def
self
.
push_to_primary_message
(
url
,
action
)
return
unless
url
&&
action
# This is formatted like this to fit into the console 'box', e.g.
#
# remote:
# remote: You're pushing to a Geo secondary! We'll help you by <action> this
# remote: request to the primary:
# remote:
# remote: <url>
# remote:
template
=
<<~
STR
You're pushing to a Geo secondary! We'll help you by %{action} this
request to the primary:
%{url}
STR
_
(
template
)
%
{
action:
_
(
action
),
url:
url
}
end
end
end
ee/spec/lib/gitlab/geo_spec.rb
View file @
23d9ea0a
...
...
@@ -307,4 +307,32 @@ describe Gitlab::Geo, :geo, :request_store do
end
end
end
describe
'.proxying_to_primary_message'
do
it
'returns a message as a string'
do
url
=
'ssh://git@primary.com/namespace/repo.git'
message
=
<<~
STR
You're pushing to a Geo secondary! We'll help you by proxying this
request to the primary:
#{
url
}
STR
expect
(
described_class
.
proxying_push_to_primary_message
(
url
)).
to
eq
(
message
)
end
end
describe
'.redirecting_to_primary_message'
do
it
'returns a message as a string'
do
url
=
'http://primary.com/namespace/repo.git'
message
=
<<~
STR
You're pushing to a Geo secondary! We'll help you by redirecting this
request to the primary:
#{
url
}
STR
expect
(
described_class
.
redirecting_push_to_primary_message
(
url
)).
to
eq
(
message
)
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