Commit bddb3c14 authored by Michael Kozono's avatar Michael Kozono

Add geo node name setting

parent 62ccb122
......@@ -407,6 +407,16 @@ production: &base
# dsn: https://<key>@sentry.io/<project>
# environment: 'production' # e.g. development, staging, production
## Geo
# NOTE: These settings will only take effect if Geo is enabled
geo:
# This is an optional identifier which Geo nodes can use to identify themselves.
# For example, if external_url is the same for two secondaries, you must specify
# a unique Geo node name for those secondaries.
#
# If it is blank, it defaults to external_url.
node_name: ''
#
# 2. GitLab CI settings
# ==========================
......
......@@ -268,6 +268,9 @@ Settings.pages.admin['certificate'] ||= ''
#
# Geo
#
Settings['geo'] ||= Settingslogic.new({})
# For backwards compatibility, default to gitlab_url and if so, ensure it ends with "/"
Settings.geo['node_name'] = Settings.geo['node_name'].presence || Settings.gitlab['url'].chomp('/').concat('/')
#
# External merge request diffs
......
......@@ -55,14 +55,17 @@ class GeoNode < ApplicationRecord
encode: true
class << self
# Set in gitlab.rb as external_url
def current_node_url
RequestStore.fetch('geo_node:current_node_url') do
cfg = Gitlab.config.gitlab
uri = URI.parse("#{cfg.protocol}://#{cfg.host}:#{cfg.port}#{cfg.relative_url_root}")
uri.path += '/' unless uri.path.end_with?('/')
Gitlab.config.gitlab.url
end
end
uri.to_s
# Set in gitlab.rb as geo_node_name
def current_node_name
RequestStore.fetch('geo_node:current_node_name') do
Gitlab.config.geo.node_name
end
end
......
......@@ -10,7 +10,7 @@ describe 'geo rake tasks', :geo do
describe 'set_primary_node task' do
before do
stub_config_setting(protocol: 'https')
stub_config_setting(url: 'https://example.com:1234/relative_part')
end
it 'creates a GeoNode' do
......@@ -23,6 +23,7 @@ describe 'geo rake tasks', :geo do
node = GeoNode.first
expect(node.uri.scheme).to eq('https')
expect(node.url).to eq('https://example.com:1234/relative_part/')
expect(node.primary).to be_truthy
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