Commit 19ef3265 authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch 'mk/fix-node-name-vs-url' into 'master'

Geo: Fix GeoNode name in geo:update_primary_node_url rake task

See merge request gitlab-org/gitlab!24649
parents 3786323b eb030bea
---
title: 'Geo: Fix GeoNode name in geo:update_primary_node_url rake task'
merge_request: 24649
author:
type: fixed
......@@ -205,6 +205,25 @@ secondary domain, like changing Git remotes and API URLs.
This command will use the changed `external_url` configuration defined
in `/etc/gitlab/gitlab.rb`.
1. For GitLab 11.11 through 12.7 only, you may need to update the primary
node's name in the database. This bug has been fixed in GitLab 12.8.
To determine if you need to do this, search for the
`gitlab_rails["geo_node_name"]` setting in your `/etc/gitlab/gitlab.rb`
file. If it is commented out with `#` or not found at all, then you will
need to update the primary node's name in the database. You can search for it
like so:
```shell
grep "geo_node_name" /etc/gitlab/gitlab.rb
```
To update the primary node's name in the database:
```shell
gitlab-rails runner 'Gitlab::Geo.primary_node.update!(name: GeoNode.current_node_name)'
```
1. Verify you can connect to the newly promoted **primary** using its URL.
If you updated the DNS records for the primary domain, these changes may
not have yet propagated depending on the previous DNS records TTL.
......
......@@ -27,7 +27,7 @@ module Gitlab
$stdout.puts "Updating primary Geo node with URL #{node.url} ..."
if node.update(url: GeoNode.current_node_url)
if node.update(name: GeoNode.current_node_name, url: GeoNode.current_node_url)
$stdout.puts "#{node.url} is now the primary Geo node URL".color(:green)
else
$stdout.puts "Error saving Geo node:\n#{node.errors.full_messages.join("\n")}".color(:red)
......
......@@ -283,17 +283,41 @@ describe 'geo rake tasks', :geo do
end
describe 'geo:update_primary_node_url' do
let(:primary_node) { create(:geo_node, :primary, url: 'https://secondary.geo.example.com') }
before do
allow(GeoNode).to receive(:current_node_url).and_return('https://primary.geo.example.com')
stub_current_geo_node(primary_node)
end
it 'updates Geo primary node URL' do
run_rake_task('geo:update_primary_node_url')
context 'when the machine Geo node name is not explicitly configured' do
let(:primary_node) { create(:geo_node, :primary, url: 'https://secondary.geo.example.com', name: 'https://secondary.geo.example.com') }
before do
# As if Gitlab.config.geo.node_name is defaulting to external_url (this happens in an initializer)
allow(GeoNode).to receive(:current_node_name).and_return('https://primary.geo.example.com')
end
it 'updates Geo primary node URL and name' do
run_rake_task('geo:update_primary_node_url')
expect(primary_node.reload.url).to eq 'https://primary.geo.example.com/'
expect(primary_node.name).to eq 'https://primary.geo.example.com/'
end
end
context 'when the machine Geo node name is explicitly configured' do
let(:node_name) { 'Brazil DC' }
let(:primary_node) { create(:geo_node, :primary, url: 'https://secondary.geo.example.com', name: node_name) }
expect(primary_node.reload.url).to eq 'https://primary.geo.example.com/'
before do
allow(GeoNode).to receive(:current_node_name).and_return(node_name)
end
it 'updates Geo primary node URL only' do
run_rake_task('geo:update_primary_node_url')
expect(primary_node.reload.url).to eq 'https://primary.geo.example.com/'
expect(primary_node.name).to eq node_name
end
end
end
......
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