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
e30e9a9b
Commit
e30e9a9b
authored
Sep 11, 2019
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use gl_console_messages in favour of info_message
parent
a9536dd6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
20 deletions
+51
-20
doc/administration/geo/replication/using_a_geo_server.md
doc/administration/geo/replication/using_a_geo_server.md
+6
-2
ee/lib/ee/gitlab/geo_git_access.rb
ee/lib/ee/gitlab/geo_git_access.rb
+35
-16
ee/spec/support/shared_examples/git_access_shared_examples.rb
...pec/support/shared_examples/git_access_shared_examples.rb
+10
-2
No files found.
doc/administration/geo/replication/using_a_geo_server.md
View file @
e30e9a9b
...
...
@@ -10,8 +10,12 @@ Example of the output you will see when pushing to a **secondary** node:
```
bash
$
git push
>
GitLab: You
're pushing to a Geo secondary.
> GitLab: We'
ll
help
you by proxying this request to the primary: ssh://git@primary.geo/user/repo.git
remote:
remote: You
're pushing to a Geo secondary. We'
ll
help
you by proxying this
remote: request to the primary:
remote:
remote: ssh://git@primary.geo/user/repo.git
remote:
Everything up-to-date
```
...
...
ee/lib/ee/gitlab/geo_git_access.rb
View file @
e30e9a9b
...
...
@@ -21,7 +21,7 @@ module EE
override
:check_for_console_messages
def
check_for_console_messages
(
cmd
)
super
.
push
(
*
current_replication_lag_message
(
cmd
)
*
current_replication_lag_message
)
end
...
...
@@ -33,18 +33,6 @@ module EE
private
def
current_replication_lag_message
(
cmd
)
return
unless
upload_pack?
(
cmd
)
# git fetch / pull
return
unless
::
Gitlab
::
Database
.
read_only?
return
unless
current_replication_lag
>
0
"Current replication lag:
#{
current_replication_lag
}
seconds"
end
def
current_replication_lag
@current_replication_lag
||=
::
Gitlab
::
Geo
::
HealthCheck
.
new
.
db_replication_lag_seconds
end
def
custom_action_for?
(
cmd
)
return
unless
receive_pack?
(
cmd
)
# git push
return
unless
::
Gitlab
::
Database
.
read_only?
...
...
@@ -58,13 +46,21 @@ module EE
payload
=
{
'action'
=>
'geo_proxy_to_primary'
,
'data'
=>
{
'info_message'
=>
proxying_to_primary_message
,
'api_endpoints'
=>
custom_action_api_endpoints
,
'primary_repo'
=>
primary_http_repo_url
}
}
::
Gitlab
::
GitAccessResult
::
CustomAction
.
new
(
payload
,
'Attempting to proxy to primary.'
)
::
Gitlab
::
GitAccessResult
::
CustomAction
.
new
(
payload
,
'Attempting to proxy to primary.'
,
messages
)
end
def
messages
messages
=
proxying_to_primary_message
lag_message
=
current_replication_lag_message
return
messages
unless
lag_message
messages
+
[
''
,
lag_message
]
end
def
push_to_read_only_message
...
...
@@ -95,7 +91,30 @@ module EE
end
def
proxying_to_primary_message
"You're pushing to a Geo secondary.
\n
We'll help you by proxying this request to the primary:
#{
primary_ssh_url_to_repo
}
"
# 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?
"Current replication lag:
#{
current_replication_lag
}
seconds"
end
def
current_replication_lag
@current_replication_lag
||=
::
Gitlab
::
Geo
::
HealthCheck
.
new
.
db_replication_lag_seconds
end
def
custom_action_api_endpoints
...
...
ee/spec/support/shared_examples/git_access_shared_examples.rb
View file @
e30e9a9b
...
...
@@ -8,8 +8,9 @@ shared_examples 'a read-only GitLab instance' do
end
context
'for a Geo setup'
do
let
(
:primary_node
)
{
create
(
:geo_node
,
:primary
,
url:
'https://localhost:3000/gitlab'
)
}
before
do
primary_node
=
create
(
:geo_node
,
:primary
,
url:
'https://localhost:3000/gitlab'
)
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary
).
and_return
(
primary_node
)
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary_with_primary?
).
and_return
(
secondary_with_primary
)
end
...
...
@@ -31,12 +32,19 @@ shared_examples 'a read-only GitLab instance' do
{
'action'
=>
'geo_proxy_to_primary'
,
'data'
=>
{
'info_message'
=>
"You're pushing to a Geo secondary.
\n
We'll help you by proxying this request to the primary:
#{
primary_repo_ssh_url
}
"
,
'api_endpoints'
=>
%w{/api/v4/geo/proxy_git_push_ssh/info_refs /api/v4/geo/proxy_git_push_ssh/push}
,
'primary_repo'
=>
primary_repo_url
}
}
end
let
(
:console_messages
)
do
[
"You're pushing to a Geo secondary! We'll help you by proxying this"
,
"request to the primary:"
,
""
,
"
#{
primary_repo_ssh_url
}
"
]
end
it
'attempts to proxy to the primary'
do
project
.
add_maintainer
(
user
)
...
...
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