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
84b1d700
Commit
84b1d700
authored
Mar 27, 2020
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify Geo proxying/redirecting messages
In the future we'll be supporting not only push but also clone/pull.
parent
cdf6a458
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
30 deletions
+22
-30
ee/lib/ee/api/internal/base.rb
ee/lib/ee/api/internal/base.rb
+1
-1
ee/lib/ee/gitlab/geo_git_access.rb
ee/lib/ee/gitlab/geo_git_access.rb
+1
-1
ee/lib/gitlab/geo.rb
ee/lib/gitlab/geo.rb
+7
-15
ee/spec/lib/gitlab/geo_spec.rb
ee/spec/lib/gitlab/geo_spec.rb
+6
-6
ee/spec/requests/api/internal/base_spec.rb
ee/spec/requests/api/internal/base_spec.rb
+2
-2
ee/spec/support/shared_examples/lib/gitlab/git_access_shared_examples.rb
.../shared_examples/lib/gitlab/git_access_shared_examples.rb
+2
-2
qa/qa/specs/features/ee/browser_ui/geo/ssh_push_to_secondary_spec.rb
.../features/ee/browser_ui/geo/ssh_push_to_secondary_spec.rb
+2
-2
qa/qa/specs/features/ee/browser_ui/geo/wiki_ssh_push_to_secondary_spec.rb
...ures/ee/browser_ui/geo/wiki_ssh_push_to_secondary_spec.rb
+1
-1
No files found.
ee/lib/ee/api/internal/base.rb
View file @
84b1d700
...
...
@@ -51,7 +51,7 @@ module EE
@geo_redirect_to_primary_message
||=
begin
url
=
"
#{
::
Gitlab
::
Geo
.
current_node
.
url
.
chomp
(
'/'
)
}
/
#{
project
.
full_path
}
.git"
::
Gitlab
::
Geo
.
redirecting_push_to
_primary_message
(
url
)
::
Gitlab
::
Geo
.
interacting_with
_primary_message
(
url
)
end
end
...
...
ee/lib/ee/gitlab/geo_git_access.rb
View file @
84b1d700
...
...
@@ -40,7 +40,7 @@ module EE
end
def
messages
messages
=
::
Gitlab
::
Geo
.
proxying_push_to
_primary_message
(
primary_ssh_url_to_repo
).
split
(
"
\n
"
)
messages
=
::
Gitlab
::
Geo
.
interacting_with
_primary_message
(
primary_ssh_url_to_repo
).
split
(
"
\n
"
)
lag_message
=
current_replication_lag_message
return
messages
unless
lag_message
...
...
ee/lib/gitlab/geo.rb
View file @
84b1d700
...
...
@@ -137,33 +137,25 @@ 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
def
self
.
interacting_with_primary_message
(
url
)
return
unless
url
# 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:
This request to a Geo secondary node will be forwarded to the
# remote:
Geo primary node
:
# remote:
# remote: <url>
# remote:
template
=
<<~
STR
You're pushing to a Geo secondary! We'll help you by %{action} this
request to the primary
:
This request to a Geo secondary node will be forwarded to the
Geo primary node
:
%{url}
STR
_
(
template
)
%
{
action:
_
(
action
),
url:
url
}
_
(
template
)
%
{
url:
url
}
end
end
end
ee/spec/lib/gitlab/geo_spec.rb
View file @
84b1d700
...
...
@@ -312,13 +312,13 @@ describe Gitlab::Geo, :geo, :request_store 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
:
This request to a Geo secondary node will be forwarded to the
Geo primary node
:
#{
url
}
STR
expect
(
described_class
.
proxying_push_to
_primary_message
(
url
)).
to
eq
(
message
)
expect
(
described_class
.
interacting_with
_primary_message
(
url
)).
to
eq
(
message
)
end
end
...
...
@@ -326,13 +326,13 @@ describe Gitlab::Geo, :geo, :request_store 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
:
This request to a Geo secondary node will be forwarded to the
Geo primary node
:
#{
url
}
STR
expect
(
described_class
.
redirecting_push_to
_primary_message
(
url
)).
to
eq
(
message
)
expect
(
described_class
.
interacting_with
_primary_message
(
url
)).
to
eq
(
message
)
end
end
end
ee/spec/requests/api/internal/base_spec.rb
View file @
84b1d700
...
...
@@ -101,8 +101,8 @@ describe API::Internal::Base do
it
'includes a message advising a redirection occurred'
do
redirect_message
=
<<~
STR
You're pushing to a Geo secondary! We'll help you by redirecting this
request to the primary
:
This request to a Geo secondary node will be forwarded to the
Geo primary node
:
http://primary.example.com/
#{
project
.
full_path
}
.git
STR
...
...
ee/spec/support/shared_examples/lib/gitlab/git_access_shared_examples.rb
View file @
84b1d700
...
...
@@ -39,8 +39,8 @@ RSpec.shared_examples 'a read-only GitLab instance' do
end
let
(
:console_messages
)
do
[
"
You're pushing to a Geo secondary! We'll help you by proxying this
"
,
"
request to the primary
:"
,
"
This request to a Geo secondary node will be forwarded to the
"
,
"
Geo primary node
:"
,
""
,
"
#{
primary_repo_ssh_url
}
"
]
...
...
qa/qa/specs/features/ee/browser_ui/geo/ssh_push_to_secondary_spec.rb
View file @
84b1d700
...
...
@@ -83,7 +83,7 @@ module QA
# as ssh:// can appear depending on how GitLab is configured.
ssh_uri
=
project
.
repository_ssh_location
.
git_uri
.
to_s
.
gsub
(
%r{ssh://}
,
''
)
expect
(
push
.
output
).
to
match
(
%r{
We'll help you by proxying this.*request to the primary
:.*
#{
ssh_uri
}
}m
)
expect
(
push
.
output
).
to
match
(
%r{
This request to a Geo secondary node will be forwarded to the.*Geo primary node
:.*
#{
ssh_uri
}
}m
)
# Validate git push worked and new content is visible
Page
::
Project
::
Show
.
perform
do
|
show
|
...
...
@@ -171,7 +171,7 @@ module QA
end
ssh_uri
=
project
.
repository_ssh_location
.
git_uri
.
to_s
.
gsub
(
%r{ssh://}
,
''
)
expect
(
push
.
output
).
to
match
(
%r{
We'll help you by proxying this.*request to the primary
:.*
#{
ssh_uri
}
}m
)
expect
(
push
.
output
).
to
match
(
%r{
This request to a Geo secondary node will be forwarded to the.*Geo primary node
:.*
#{
ssh_uri
}
}m
)
expect
(
push
.
output
).
to
match
(
/Locking support detected on remote "
#{
location
.
uri
}
"/
)
# Validate git push worked and new content is visible
...
...
qa/qa/specs/features/ee/browser_ui/geo/wiki_ssh_push_to_secondary_spec.rb
View file @
84b1d700
...
...
@@ -86,7 +86,7 @@ module QA
# as ssh:// can appear depending on how GitLab is configured.
ssh_uri
=
wiki
.
repository_ssh_location
.
git_uri
.
to_s
.
gsub
(
%r{ssh://}
,
''
)
expect
(
push
.
output
).
to
match
(
%r{
We'll help you by proxying this.*request to the primary
:.*
#{
ssh_uri
}
}m
)
expect
(
push
.
output
).
to
match
(
%r{
This request to a Geo secondary node will be forwarded to the.*Geo primary node
:.*
#{
ssh_uri
}
}m
)
# Validate git push worked and new content is visible
Page
::
Project
::
Menu
.
perform
(
&
:click_wiki
)
...
...
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