Commit 4944db99 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch '202037-geo-ssh-clone-pull-redirect-to-primary-when-selective-sync-enabled-and-project-not-selected-pre' into 'master'

Geo: Simplify Geo proxying/redirecting messages

See merge request gitlab-org/gitlab!28178
parents b5834108 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
......
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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}"
]
......
......@@ -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
......
......@@ -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)
......
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