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
749590ed
Commit
749590ed
authored
Nov 05, 2021
by
Gabriel Mazetto
Committed by
Alex Kalderimis
Nov 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a rake task to print current Geo Site role
parent
53e2348c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
4 deletions
+54
-4
ee/lib/tasks/geo.rake
ee/lib/tasks/geo.rake
+24
-4
ee/spec/tasks/geo_rake_spec.rb
ee/spec/tasks/geo_rake_spec.rb
+30
-0
No files found.
ee/lib/tasks/geo.rake
View file @
749590ed
...
...
@@ -170,12 +170,12 @@ namespace :geo do
current_max_id
=
[
from_project_id
+
batch_size
,
to_project_id
+
1
].
min
project_ids
=
Project
.
where
(
'id >= ? AND id < ?'
,
from_project_id
,
current_max_id
)
.
pluck_primary_key
.
where
(
'id >= ? AND id < ?'
,
from_project_id
,
current_max_id
)
.
pluck_primary_key
orphaned_registries
=
Geo
::
ProjectRegistry
.
where
(
'project_id NOT IN(?)'
,
project_ids
)
.
where
(
'project_id >= ? AND project_id < ?'
,
from_project_id
,
current_max_id
)
.
where
(
'project_id NOT IN(?)'
,
project_ids
)
.
where
(
'project_id >= ? AND project_id < ?'
,
from_project_id
,
current_max_id
)
count
=
orphaned_registries
.
delete_all
total_count
+=
count
...
...
@@ -214,6 +214,10 @@ namespace :geo do
abort
GEO_LICENSE_ERROR_TEXT
unless
Gitlab
::
Geo
.
license_allows?
current_node_status
=
GeoNodeStatus
.
current_node_status
unless
current_node_status
abort
'Gitlab Geo is not configured for this site'
end
geo_node
=
current_node_status
.
geo_node
unless
geo_node
.
secondary?
...
...
@@ -223,4 +227,20 @@ namespace :geo do
Gitlab
::
Geo
::
GeoNodeStatusCheck
.
new
(
current_node_status
,
geo_node
).
print_status
end
namespace
:site
do
desc
'GitLab | Geo | Print Geo site role'
task
role: :environment
do
current_node
=
GeoNode
.
current_node
if
current_node
&
.
primary?
puts
'primary'
elsif
current_node
&
.
secondary?
puts
'secondary'
else
puts
'misconfigured'
exit
1
end
end
end
end
ee/spec/tasks/geo_rake_spec.rb
View file @
749590ed
...
...
@@ -309,6 +309,12 @@ RSpec.describe 'geo rake tasks', :geo, :silence_stdout do
end
describe
'geo:status'
do
context
'when geo is not properly configured'
do
it
'returns misconfigured when not a primary nor a secondary site'
do
expect
{
run_rake_task
(
'geo:status'
)
}.
to
raise_error
(
"Gitlab Geo is not configured for this site"
)
end
end
context
'without a valid license'
do
before
do
stub_licensed_features
(
geo:
false
)
...
...
@@ -398,6 +404,30 @@ RSpec.describe 'geo rake tasks', :geo, :silence_stdout do
end
end
describe
'geo:site:role'
do
context
'when in a primary site'
do
it
'returns primary'
do
create
(
:geo_node
,
:primary
,
name:
'primary'
)
allow
(
GeoNode
).
to
receive
(
:current_node_name
).
and_return
(
'primary'
)
expect
{
run_rake_task
(
'geo:site:role'
)
}.
to
output
(
/primary/
).
to_stdout
end
end
context
'when in a secondary site'
do
it
'returns secondary'
do
create
(
:geo_node
,
:secondary
,
name:
'secondary'
)
allow
(
GeoNode
).
to
receive
(
:current_node_name
).
and_return
(
'secondary'
)
expect
{
run_rake_task
(
'geo:site:role'
)
}.
to
output
(
/secondary/
).
to_stdout
end
end
it
'returns misconfigured when not a primary nor a secondary site'
do
expect
{
run_rake_task
(
'geo:site:role'
)
}.
to
output
(
/misconfigured/
).
to_stdout
&
raise_error
(
SystemExit
)
end
end
describe
'geo:run_orphaned_project_registry_cleaner'
do
let!
(
:current_node
)
{
create
(
:geo_node
)
}
...
...
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