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
0478f717
Commit
0478f717
authored
Nov 27, 2017
by
Valery Sizov
Committed by
Nick Thomas
Nov 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a rake task to turn a Geo secondary node into a Geo primary node
parent
e18207d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
29 deletions
+49
-29
changelogs/unreleased-ee/1921-improve-process-to-designate-a-secondary-node-as-primary.yml
...rove-process-to-designate-a-secondary-node-as-primary.yml
+5
-0
doc/gitlab-geo/disaster-recovery.md
doc/gitlab-geo/disaster-recovery.md
+1
-29
lib/tasks/geo.rake
lib/tasks/geo.rake
+23
-0
spec/tasks/geo_rake_spec.rb
spec/tasks/geo_rake_spec.rb
+20
-0
No files found.
changelogs/unreleased-ee/1921-improve-process-to-designate-a-secondary-node-as-primary.yml
0 → 100644
View file @
0478f717
---
title
:
Add geo:set_secondary_as_primary rake task
merge_request
:
author
:
type
:
added
doc/gitlab-geo/disaster-recovery.md
View file @
0478f717
...
...
@@ -30,35 +30,7 @@ You must make the changes in the exact specific order:
```bash
sudo rm ~git/.ssh/id_rsa ~git/.ssh/id_rsa.pub
```
1.
Open the interactive rails console:
`sudo gitlab-rails console`
and execute:
*
List your primary node and note down it's id:
```ruby
Gitlab::Geo.primary_node
```
* Remove the old primary node:
```ruby
Gitlab::Geo.primary_node.destroy
```
* List your secondary nodes and note down the id of the one you want to promote:
```ruby
Gitlab::Geo.secondary_nodes
```
* To promote a node with id `2` execute:
```ruby
GeoNode.find(2).update!(primary: true)
```
* Now you have to cleanup your new promoted node by running:
```ruby
Gitlab::Geo.primary_node.oauth_application.destroy!
Gitlab::Geo.primary_node.system_hook.destroy!
```
* To exit the interactive console, type: `exit`
1.
Run
`sudo gitlab-rake geo:set_secondary_as_primary`
1.
Rsync everything in
`/var/opt/gitlab/gitlab-rails/uploads`
and
`/var/opt/gitlab/gitlab-rails/shared`
from your old node to the new one.
...
...
lib/tasks/geo.rake
View file @
0478f717
...
...
@@ -151,6 +151,29 @@ namespace :geo do
set_primary_geo_node
end
desc
'Make this secondary node the primary'
task
set_secondary_as_primary: :environment
do
abort
'GitLab Geo is not supported with this license. Please contact sales@gitlab.com.'
unless
Gitlab
::
Geo
.
license_allows?
ActiveRecord
::
Base
.
transaction
do
primary_node
=
Gitlab
::
Geo
.
primary_node
unless
primary_node
abort
'The primary is not set'
end
primary_node
.
destroy
current_node
=
Gitlab
::
Geo
.
current_node
unless
current_node
.
secondary?
abort
'This is not a secondary node'
end
current_node
.
update!
(
primary:
true
)
end
end
def
set_primary_geo_node
params
=
{
schema:
Gitlab
.
config
.
gitlab
.
protocol
,
...
...
spec/tasks/geo_rake_spec.rb
View file @
0478f717
...
...
@@ -25,4 +25,24 @@ describe 'geo rake tasks' do
expect
(
node
.
geo_node_key
).
to
be_nil
end
end
describe
'set_secondary_as_primary task'
do
include
::
EE
::
GeoHelpers
let!
(
:current_node
)
{
create
(
:geo_node
)
}
let!
(
:primary_node
)
{
create
(
:geo_node
,
:primary
)
}
before
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:license_allows?
).
and_return
(
true
)
stub_current_geo_node
(
current_node
)
end
it
'removes primary and sets secondary as primary'
do
run_rake_task
(
'geo:set_secondary_as_primary'
)
expect
(
current_node
.
primary?
).
to
be_truthy
expect
(
GeoNode
.
count
).
to
eq
(
1
)
end
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