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
651dd5cf
Commit
651dd5cf
authored
Oct 18, 2021
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not update Geo node if running on a primary site
Changelog: changed EE: true
parent
5ca5f2a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
11 deletions
+16
-11
ee/lib/gitlab/geo/geo_tasks.rb
ee/lib/gitlab/geo/geo_tasks.rb
+8
-5
ee/spec/lib/gitlab/geo/geo_tasks_spec.rb
ee/spec/lib/gitlab/geo/geo_tasks_spec.rb
+8
-6
No files found.
ee/lib/gitlab/geo/geo_tasks.rb
View file @
651dd5cf
...
@@ -22,14 +22,17 @@ module Gitlab
...
@@ -22,14 +22,17 @@ module Gitlab
primary_node
=
GeoNode
.
primary_node
primary_node
=
GeoNode
.
primary_node
current_node
=
GeoNode
.
current_node
current_node
=
GeoNode
.
current_node
abort
'The primary is not set'
unless
primary_node
abort
'The primary
Geo site
is not set'
unless
primary_node
abort
'Current node is not identified'
unless
current_node
abort
'Current node is not identified'
unless
current_node
abort
'This is not a secondary node'
unless
current_node
.
secondary?
if
current_node
.
primary?
$stdout
.
puts
"
#{
current_node
.
url
}
is already the primary Geo site"
.
color
(
:green
)
else
primary_node
.
destroy
primary_node
.
destroy
current_node
.
update!
(
primary:
true
,
enabled:
true
)
current_node
.
update!
(
primary:
true
,
enabled:
true
)
$stdout
.
puts
"
#{
current_node
.
url
}
is now the primary Geo node"
.
color
(
:green
)
$stdout
.
puts
"
#{
current_node
.
url
}
is now the primary Geo site"
.
color
(
:green
)
end
end
end
end
end
...
...
ee/spec/lib/gitlab/geo/geo_tasks_spec.rb
View file @
651dd5cf
...
@@ -35,7 +35,7 @@ RSpec.describe Gitlab::Geo::GeoTasks do
...
@@ -35,7 +35,7 @@ RSpec.describe Gitlab::Geo::GeoTasks do
it
'aborts if the primary node is not set'
do
it
'aborts if the primary node is not set'
do
primary
.
update_column
(
:primary
,
false
)
primary
.
update_column
(
:primary
,
false
)
expect
(
subject
).
to
receive
(
:abort
).
with
(
'The primary is not set'
).
and_raise
(
'aborted'
)
expect
(
subject
).
to
receive
(
:abort
).
with
(
'The primary
Geo site
is not set'
).
and_raise
(
'aborted'
)
expect
{
subject
.
set_secondary_as_primary
}.
to
raise_error
(
'aborted'
)
expect
{
subject
.
set_secondary_as_primary
}.
to
raise_error
(
'aborted'
)
end
end
...
@@ -48,19 +48,21 @@ RSpec.describe Gitlab::Geo::GeoTasks do
...
@@ -48,19 +48,21 @@ RSpec.describe Gitlab::Geo::GeoTasks do
expect
{
subject
.
set_secondary_as_primary
}.
to
raise_error
(
'aborted'
)
expect
{
subject
.
set_secondary_as_primary
}.
to
raise_error
(
'aborted'
)
end
end
it
'
aborts
if run on a node that is not a secondary'
do
it
'
does nothing
if run on a node that is not a secondary'
do
primary
.
update_column
(
:primary
,
false
)
primary
.
update_column
(
:primary
,
false
)
secondary
.
update!
(
primary:
true
)
secondary
.
update!
(
primary:
true
)
expect
(
subject
).
to
receive
(
:abort
).
with
(
'This is not a secondary node'
).
and_raise
(
'aborted'
)
expect
(
subject
).
not_to
receive
(
:abort
)
expect
{
subject
.
set_secondary_as_primary
}.
to
raise_error
(
'aborted'
)
expect
{
subject
.
set_secondary_as_primary
}.
to
output
(
/
#{
secondary
.
url
}
is already the primary Geo site/
).
to_stdout
expect
(
secondary
.
reload
).
to
be_primary
expect
(
primary
.
reload
).
to
be_secondary
end
end
it
'sets the secondary as the primary node'
do
it
'sets the secondary as the primary node'
do
expect
(
subject
).
not_to
receive
(
:abort
)
expect
(
subject
).
not_to
receive
(
:abort
)
expect
{
subject
.
set_secondary_as_primary
}.
to
output
(
/
#{
secondary
.
url
}
is now the primary Geo
nod
e/
).
to_stdout
expect
{
subject
.
set_secondary_as_primary
}.
to
output
(
/
#{
secondary
.
url
}
is now the primary Geo
sit
e/
).
to_stdout
expect
(
secondary
.
reload
).
to
be_primary
expect
(
secondary
.
reload
).
to
be_primary
end
end
...
@@ -69,7 +71,7 @@ RSpec.describe Gitlab::Geo::GeoTasks do
...
@@ -69,7 +71,7 @@ RSpec.describe Gitlab::Geo::GeoTasks do
expect
(
subject
).
not_to
receive
(
:abort
)
expect
(
subject
).
not_to
receive
(
:abort
)
expect
{
subject
.
set_secondary_as_primary
}.
to
output
(
/
#{
secondary
.
url
}
is now the primary Geo
nod
e/
).
to_stdout
expect
{
subject
.
set_secondary_as_primary
}.
to
output
(
/
#{
secondary
.
url
}
is now the primary Geo
sit
e/
).
to_stdout
expect
(
secondary
.
reload
).
to
be_primary
expect
(
secondary
.
reload
).
to
be_primary
expect
(
secondary
.
reload
).
to
be_enabled
expect
(
secondary
.
reload
).
to
be_enabled
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