Skip to content
Snippets Groups Projects
Commit 00d3ac3e authored by Robert Marshall's avatar Robert Marshall
Browse files

Merge branch 'move-geo-postgresql-to-underscored-form' into 'master'

parents 614c9924 fc83cf85
No related branches found
No related tags found
No related merge requests found
Showing
with 134 additions and 125 deletions
Loading
Loading
@@ -79,80 +79,80 @@ default['gitlab']['geo_secondary']['db_database_tasks'] = true
# Geo: PostgreSQL (Tracking database)
###
 
default['gitlab']['geo-postgresql'] = default['postgresql'].dup
default['gitlab']['geo_postgresql'] = default['postgresql'].dup
# We are inheriting default attributes from postgresql and changing below what should be different
default['gitlab']['geo-postgresql']['enable'] = false
default['gitlab']['geo-postgresql']['dir'] = '/var/opt/gitlab/geo-postgresql'
default['gitlab']['geo-postgresql']['log_directory'] = '/var/log/gitlab/geo-postgresql'
default['gitlab']['geo-postgresql']['unix_socket_directory'] = nil
default['gitlab']['geo-postgresql']['ssl'] = 'off'
default['gitlab']['geo_postgresql']['enable'] = false
default['gitlab']['geo_postgresql']['dir'] = '/var/opt/gitlab/geo-postgresql'
default['gitlab']['geo_postgresql']['log_directory'] = '/var/log/gitlab/geo-postgresql'
default['gitlab']['geo_postgresql']['unix_socket_directory'] = nil
default['gitlab']['geo_postgresql']['ssl'] = 'off'
# Postgres User's Environment Path
default['gitlab']['geo-postgresql']['sql_user'] = 'gitlab_geo'
default['gitlab']['geo-postgresql']['sql_mattermost_user'] = nil
default['gitlab']['geo-postgresql']['port'] = 5431
default['gitlab']['geo_postgresql']['sql_user'] = 'gitlab_geo'
default['gitlab']['geo_postgresql']['sql_mattermost_user'] = nil
default['gitlab']['geo_postgresql']['port'] = 5431
 
# Mininum of 1/8 of total memory and Maximum of 1024MB as sane defaults
default['gitlab']['geo-postgresql']['shared_buffers'] = "#{[(node['memory']['total'].to_i / 8) / 1024, 1024].max}MB"
default['gitlab']['geo_postgresql']['shared_buffers'] = "#{[(node['memory']['total'].to_i / 8) / 1024, 1024].max}MB"
 
default['gitlab']['geo-postgresql']['work_mem'] = '16MB'
default['gitlab']['geo-postgresql']['maintenance_work_mem'] = '16MB'
default['gitlab']['geo-postgresql']['effective_cache_size'] = "#{[(node['memory']['total'].to_i / 8) / 1024, 2048].max}MB" # double of shared_buffers estimation
default['gitlab']['geo-postgresql']['log_min_duration_statement'] = -1 # Disable slow query logging by default
default['gitlab']['geo-postgresql']['min_wal_size'] = '80MB'
default['gitlab']['geo-postgresql']['max_wal_size'] = '1GB'
default['gitlab']['geo-postgresql']['checkpoint_timeout'] = '5min'
default['gitlab']['geo-postgresql']['checkpoint_completion_target'] = 0.9
default['gitlab']['geo-postgresql']['checkpoint_warning'] = '30s'
default['gitlab']['geo-postgresql']['wal_buffers'] = '-1'
default['gitlab']['geo-postgresql']['autovacuum'] = 'on'
default['gitlab']['geo-postgresql']['log_autovacuum_min_duration'] = '-1'
default['gitlab']['geo-postgresql']['autovacuum_max_workers'] = '3'
default['gitlab']['geo-postgresql']['autovacuum_naptime'] = '1min'
default['gitlab']['geo-postgresql']['autovacuum_vacuum_threshold'] = '50'
default['gitlab']['geo-postgresql']['autovacuum_analyze_threshold'] = '50'
default['gitlab']['geo-postgresql']['autovacuum_vacuum_scale_factor'] = '0.02' # 10x lower than PG defaults
default['gitlab']['geo-postgresql']['autovacuum_analyze_scale_factor'] = '0.01' # 10x lower than PG defaults
default['gitlab']['geo-postgresql']['autovacuum_freeze_max_age'] = '200000000'
default['gitlab']['geo-postgresql']['autovacuum_vacuum_cost_delay'] = '20ms'
default['gitlab']['geo-postgresql']['autovacuum_vacuum_cost_limit'] = '-1'
default['gitlab']['geo-postgresql']['statement_timeout'] = '60000'
default['gitlab']['geo-postgresql']['idle_in_transaction_session_timeout'] = '60000'
default['gitlab']['geo-postgresql']['log_line_prefix'] = nil
default['gitlab']['geo-postgresql']['track_activity_query_size'] = '1024'
default['gitlab']['geo-postgresql']['effective_io_concurrency'] = 1
default['gitlab']['geo-postgresql']['max_worker_processes'] = 8
default['gitlab']['geo-postgresql']['max_parallel_workers_per_gather'] = 0
default['gitlab']['geo-postgresql']['log_lock_waits'] = 1
default['gitlab']['geo-postgresql']['deadlock_timeout'] = '5s'
default['gitlab']['geo-postgresql']['track_io_timing'] = 'off'
default['gitlab']['geo-postgresql']['custom_pg_hba_entries'] = {}
default['gitlab']['geo-postgresql']['default_statistics_target'] = 1000
default['gitlab']['geo_postgresql']['work_mem'] = '16MB'
default['gitlab']['geo_postgresql']['maintenance_work_mem'] = '16MB'
default['gitlab']['geo_postgresql']['effective_cache_size'] = "#{[(node['memory']['total'].to_i / 8) / 1024, 2048].max}MB" # double of shared_buffers estimation
default['gitlab']['geo_postgresql']['log_min_duration_statement'] = -1 # Disable slow query logging by default
default['gitlab']['geo_postgresql']['min_wal_size'] = '80MB'
default['gitlab']['geo_postgresql']['max_wal_size'] = '1GB'
default['gitlab']['geo_postgresql']['checkpoint_timeout'] = '5min'
default['gitlab']['geo_postgresql']['checkpoint_completion_target'] = 0.9
default['gitlab']['geo_postgresql']['checkpoint_warning'] = '30s'
default['gitlab']['geo_postgresql']['wal_buffers'] = '-1'
default['gitlab']['geo_postgresql']['autovacuum'] = 'on'
default['gitlab']['geo_postgresql']['log_autovacuum_min_duration'] = '-1'
default['gitlab']['geo_postgresql']['autovacuum_max_workers'] = '3'
default['gitlab']['geo_postgresql']['autovacuum_naptime'] = '1min'
default['gitlab']['geo_postgresql']['autovacuum_vacuum_threshold'] = '50'
default['gitlab']['geo_postgresql']['autovacuum_analyze_threshold'] = '50'
default['gitlab']['geo_postgresql']['autovacuum_vacuum_scale_factor'] = '0.02' # 10x lower than PG defaults
default['gitlab']['geo_postgresql']['autovacuum_analyze_scale_factor'] = '0.01' # 10x lower than PG defaults
default['gitlab']['geo_postgresql']['autovacuum_freeze_max_age'] = '200000000'
default['gitlab']['geo_postgresql']['autovacuum_vacuum_cost_delay'] = '20ms'
default['gitlab']['geo_postgresql']['autovacuum_vacuum_cost_limit'] = '-1'
default['gitlab']['geo_postgresql']['statement_timeout'] = '60000'
default['gitlab']['geo_postgresql']['idle_in_transaction_session_timeout'] = '60000'
default['gitlab']['geo_postgresql']['log_line_prefix'] = nil
default['gitlab']['geo_postgresql']['track_activity_query_size'] = '1024'
default['gitlab']['geo_postgresql']['effective_io_concurrency'] = 1
default['gitlab']['geo_postgresql']['max_worker_processes'] = 8
default['gitlab']['geo_postgresql']['max_parallel_workers_per_gather'] = 0
default['gitlab']['geo_postgresql']['log_lock_waits'] = 1
default['gitlab']['geo_postgresql']['deadlock_timeout'] = '5s'
default['gitlab']['geo_postgresql']['track_io_timing'] = 'off'
default['gitlab']['geo_postgresql']['custom_pg_hba_entries'] = {}
default['gitlab']['geo_postgresql']['default_statistics_target'] = 1000
 
# Replication settings
default['gitlab']['geo-postgresql']['wal_level'] = 'minimal'
default['gitlab']['geo-postgresql']['wal_log_hints'] = 'off'
default['gitlab']['geo-postgresql']['max_wal_senders'] = 0
default['gitlab']['geo-postgresql']['wal_keep_segments'] = 10
default['gitlab']['geo-postgresql']['wal_keep_size'] = nil
default['gitlab']['geo-postgresql']['hot_standby'] = 'off'
default['gitlab']['geo-postgresql']['max_standby_archive_delay'] = '30s'
default['gitlab']['geo-postgresql']['max_standby_streaming_delay'] = '30s'
default['gitlab']['geo-postgresql']['max_replication_slots'] = 0
default['gitlab']['geo-postgresql']['synchronous_commit'] = 'on'
default['gitlab']['geo-postgresql']['synchronous_standby_names'] = ''
default['gitlab']['geo-postgresql']['hot_standby_feedback'] = 'off'
default['gitlab']['geo_postgresql']['wal_level'] = 'minimal'
default['gitlab']['geo_postgresql']['wal_log_hints'] = 'off'
default['gitlab']['geo_postgresql']['max_wal_senders'] = 0
default['gitlab']['geo_postgresql']['wal_keep_segments'] = 10
default['gitlab']['geo_postgresql']['wal_keep_size'] = nil
default['gitlab']['geo_postgresql']['hot_standby'] = 'off'
default['gitlab']['geo_postgresql']['max_standby_archive_delay'] = '30s'
default['gitlab']['geo_postgresql']['max_standby_streaming_delay'] = '30s'
default['gitlab']['geo_postgresql']['max_replication_slots'] = 0
default['gitlab']['geo_postgresql']['synchronous_commit'] = 'on'
default['gitlab']['geo_postgresql']['synchronous_standby_names'] = ''
default['gitlab']['geo_postgresql']['hot_standby_feedback'] = 'off'
 
# Backup/Archive settings
default['gitlab']['geo-postgresql']['archive_mode'] = 'off'
default['gitlab']['geo-postgresql']['archive_command'] = nil
default['gitlab']['geo-postgresql']['archive_timeout'] = '0'
default['gitlab']['geo_postgresql']['archive_mode'] = 'off'
default['gitlab']['geo_postgresql']['archive_command'] = nil
default['gitlab']['geo_postgresql']['archive_timeout'] = '0'
 
# pgbouncer settings
default['gitlab']['geo-postgresql']['pgbouncer_user'] = 'pgbouncer'
default['gitlab']['geo-postgresql']['pgbouncer_user_password'] = nil
default['gitlab']['geo_postgresql']['pgbouncer_user'] = 'pgbouncer'
default['gitlab']['geo_postgresql']['pgbouncer_user_password'] = nil
 
# Automatically restart on version changes
default['gitlab']['geo-postgresql']['auto_restart_on_version_change'] = true
default['gitlab']['geo_postgresql']['auto_restart_on_version_change'] = true
 
###
# Geo: LogCursor (replication)
Loading
Loading
@@ -165,3 +165,4 @@ default['gitlab']['geo_logcursor']['env_directory'] = '/opt/gitlab/etc/geo-logcu
default['gitlab']['suggested-reviewers'] = Gitlab::Deprecations::NodeAttribute.new(proc { node['gitlab']['suggested_reviewers'].to_h }, "node['gitlab']['suggested-reviewers']", "node['gitlab']['suggested_reviewers']")
default['gitlab']['geo-secondary'] = Gitlab::Deprecations::NodeAttribute.new(proc { node['gitlab']['geo_secondary'].to_h }, "node['gitlab']['geo-secondary']", "node['gitlab']['geo_secondary']")
default['gitlab']['geo-logcursor'] = Gitlab::Deprecations::NodeAttribute.new(proc { node['gitlab']['geo_logcursor'].to_h }, "node['gitlab']['geo-logcursor']", "node['gitlab']['geo_logcursor']")
default['gitlab']['geo-postgresql'] = Gitlab::Deprecations::NodeAttribute.new(proc { node['gitlab']['geo_postgresql'].to_h }, "node['gitlab']['geo-postgresql']", "node['gitlab']['geo_postgresql']")
module GeoPostgresql
class << self
def parse_variables
postgresql_dir = Gitlab['geo_postgresql']['dir'] || node['gitlab']['geo-postgresql']['dir']
postgresql_dir = Gitlab['geo_postgresql']['dir'] || node['gitlab']['geo_postgresql']['dir']
 
Gitlab['geo_postgresql']['unix_socket_directory'] ||= postgresql_dir
Gitlab['geo_postgresql']['home'] ||= postgresql_dir
Loading
Loading
@@ -17,8 +17,8 @@ module GeoPostgresql
 
def parse_wal_keep_size
wal_segment_size = 16
wal_keep_segments = Gitlab['geo_postgresql']['wal_keep_segments'] || node['gitlab']['geo-postgresql']['wal_keep_segments']
wal_keep_size = Gitlab['geo_postgresql']['wal_keep_size'] || node['gitlab']['geo-postgresql']['wal_keep_size']
wal_keep_segments = Gitlab['geo_postgresql']['wal_keep_segments'] || node['gitlab']['geo_postgresql']['wal_keep_segments']
wal_keep_size = Gitlab['geo_postgresql']['wal_keep_size'] || node['gitlab']['geo_postgresql']['wal_keep_size']
 
Gitlab['geo_postgresql']['wal_keep_size'] = if wal_keep_size.nil?
wal_keep_segments.to_i * wal_segment_size
Loading
Loading
Loading
Loading
@@ -22,13 +22,13 @@ include_recipe 'postgresql::sysctl'
account_helper = AccountHelper.new(node)
omnibus_helper = OmnibusHelper.new(node)
 
postgresql_log_dir = node['gitlab']['geo-postgresql']['log_directory']
postgresql_log_dir = node['gitlab']['geo_postgresql']['log_directory']
postgresql_username = account_helper.postgresql_user
postgresql_data_dir = File.join(node['gitlab']['geo-postgresql']['dir'], 'data')
postgresql_data_dir = File.join(node['gitlab']['geo_postgresql']['dir'], 'data')
 
geo_pg_helper = GeoPgHelper.new(node)
 
directory node['gitlab']['geo-postgresql']['dir'] do
directory node['gitlab']['geo_postgresql']['dir'] do
owner postgresql_username
mode '0755'
recursive true
Loading
Loading
@@ -60,7 +60,7 @@ template postgresql_config do
owner postgresql_username
mode '0644'
helper(:pg_helper) { geo_pg_helper }
variables(node['gitlab']['geo-postgresql'].to_hash)
variables(node['gitlab']['geo_postgresql'].to_hash)
cookbook 'postgresql'
notifies :restart, 'runit_service[geo-postgresql]', :immediately if should_notify
end
Loading
Loading
@@ -70,7 +70,7 @@ template postgresql_runtime_config do
owner postgresql_username
mode '0644'
helper(:pg_helper) { geo_pg_helper }
variables(node['gitlab']['geo-postgresql'].to_hash)
variables(node['gitlab']['geo_postgresql'].to_hash)
cookbook 'postgresql'
notifies :run, 'execute[reload geo-postgresql]', :immediately if should_notify
end
Loading
Loading
@@ -81,7 +81,7 @@ template pg_hba_config do
source 'pg_hba.conf.erb'
owner postgresql_username
mode '0644'
variables(lazy { node['gitlab']['geo-postgresql'].to_hash })
variables(lazy { node['gitlab']['geo_postgresql'].to_hash })
cookbook 'postgresql'
notifies :restart, 'runit_service[geo-postgresql]', :immediately if should_notify
end
Loading
Loading
@@ -89,19 +89,19 @@ end
template File.join(postgresql_data_dir, 'pg_ident.conf') do
owner postgresql_username
mode '0644'
variables(node['gitlab']['geo-postgresql'].to_hash)
variables(node['gitlab']['geo_postgresql'].to_hash)
cookbook 'postgresql'
notifies :restart, 'runit_service[geo-postgresql]', :immediately if should_notify
end
 
runit_service 'geo-postgresql' do
start_down node['gitlab']['geo-postgresql']['ha']
start_down node['gitlab']['geo_postgresql']['ha']
restart_on_update false
control(['t'])
options({
log_directory: postgresql_log_dir
}.merge(params))
log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['geo-postgresql'].to_hash)
log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['geo_postgresql'].to_hash)
end
 
execute 'start geo-postgresql' do
Loading
Loading
@@ -121,12 +121,12 @@ template '/opt/gitlab/etc/gitlab-geo-psql-rc' do
group 'root'
end
 
geo_pg_port = node['gitlab']['geo-postgresql']['port']
geo_pg_user = node['gitlab']['geo-postgresql']['sql_user']
geo_pg_user_password = node['gitlab']['geo-postgresql']['sql_user_password']
geo_pg_port = node['gitlab']['geo_postgresql']['port']
geo_pg_user = node['gitlab']['geo_postgresql']['sql_user']
geo_pg_user_password = node['gitlab']['geo_postgresql']['sql_user_password']
geo_database_name = node['gitlab']['geo_secondary']['db_database']
 
if node['gitlab']['geo-postgresql']['enable']
if node['gitlab']['geo_postgresql']['enable']
postgresql_user geo_pg_user do
password "md5#{geo_pg_user_password}" unless geo_pg_user_password.nil?
helper geo_pg_helper
Loading
Loading
@@ -136,7 +136,7 @@ if node['gitlab']['geo-postgresql']['enable']
postgresql_database geo_database_name do
owner geo_pg_user
database_port geo_pg_port
database_socket node['gitlab']['geo-postgresql']['unix_socket_directory']
database_socket node['gitlab']['geo_postgresql']['unix_socket_directory']
helper geo_pg_helper
action :create
end
Loading
Loading
@@ -148,9 +148,9 @@ if node['gitlab']['geo-postgresql']['enable']
end
 
version_file 'Create version file for PostgreSQL' do
version_file_path File.join(node['gitlab']['geo-postgresql']['dir'], 'VERSION')
version_file_path File.join(node['gitlab']['geo_postgresql']['dir'], 'VERSION')
version_check_cmd "/opt/gitlab/embedded/bin/postgres --version"
notifies :restart, 'runit_service[geo-postgresql]', :immediately if node['gitlab']['geo-postgresql']['auto_restart_on_version_change'] && geo_pg_helper.is_running? && should_notify
notifies :restart, 'runit_service[geo-postgresql]', :immediately if node['gitlab']['geo_postgresql']['auto_restart_on_version_change'] && geo_pg_helper.is_running? && should_notify
end
 
ruby_block 'warn pending geo-postgresql restart' do
Loading
Loading
@@ -164,7 +164,7 @@ if node['gitlab']['geo-postgresql']['enable']
LoggingHelper.warning(message)
end
only_if { geo_pg_helper.is_running? && geo_pg_helper.running_version != geo_pg_helper.version }
not_if { node['gitlab']['geo-postgresql']['auto_restart_on_version_change'] }
not_if { node['gitlab']['geo_postgresql']['auto_restart_on_version_change'] }
end
end
 
Loading
Loading
psql_user='<%= node['postgresql']['username'] %>'
psql_group='<%= node['postgresql']['group'] %>'
psql_host='<%= node['gitlab']['geo-postgresql']['unix_socket_directory'] %>'
psql_port='<%= node['gitlab']['geo-postgresql']['port'] %>'
psql_host='<%= node['gitlab']['geo_postgresql']['unix_socket_directory'] %>'
psql_port='<%= node['gitlab']['geo_postgresql']['port'] %>'
psql_dbname='<%= node['gitlab']['geo_secondary']['db_database'] %>'
#!/bin/sh
exec 2>&1
<%= render('mount_point_check.erb') %>
exec chpst -P -U <%= node['postgresql']['username'] %>:<%= node['postgresql']['group'] %> -u <%= node['postgresql']['username'] %>:<%= node['postgresql']['group'] %> /opt/gitlab/embedded/bin/postgres -D <%= File.join(node['gitlab']['geo-postgresql']['dir'], 'data') %>
exec chpst -P -U <%= node['postgresql']['username'] %>:<%= node['postgresql']['group'] %> -u <%= node['postgresql']['username'] %>:<%= node['postgresql']['group'] %> /opt/gitlab/embedded/bin/postgres -D <%= File.join(node['gitlab']['geo_postgresql']['dir'], 'data') %>
Loading
Loading
@@ -166,9 +166,10 @@ class BasePgHelper < BaseHelper
end
 
def node_attributes
return node['gitlab'][service_name] if node['gitlab'].key?(service_name)
node_attribute_key = SettingsDSL::Utils.sanitized_key(service_name)
return node['gitlab'][node_attribute_key] if node['gitlab'].key?(node_attribute_key)
 
node[service_name]
node[node_attribute_key]
end
 
def is_standby?
Loading
Loading
@@ -202,14 +203,16 @@ class BasePgHelper < BaseHelper
end
 
def bootstrapped?
node_attribute_key = SettingsDSL::Utils.sanitized_key(service_name)
# As part of https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2078 services are
# being split to their own dedicated cookbooks, and attributes are being moved from
# node['gitlab'][service_name] to node[service_name]. Until they've been moved, we
# need to check both.
 
return File.exist?(File.join(node['gitlab'][service_name]['dir'], 'data', 'PG_VERSION')) if node['gitlab'].key?(service_name)
return File.exist?(File.join(node['gitlab'][node_attribute_key]['dir'], 'data', 'PG_VERSION')) if node['gitlab'].key?(node_attribute_key)
 
File.exist?(File.join(node[service_name]['dir'], 'data', 'PG_VERSION'))
File.exist?(File.join(node[node_attribute_key]['dir'], 'data', 'PG_VERSION'))
end
 
def psql_cmd(cmd_list)
Loading
Loading
@@ -243,12 +246,14 @@ class BasePgHelper < BaseHelper
end
 
def database_version
node_attribute_key = SettingsDSL::Utils.sanitized_key(service_name)
# As part of https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2078 services are
# being split to their own dedicated cookbooks, and attributes are being moved from
# node['gitlab'][service_name] to node[service_name]. Until they've been moved, we
# need to check both.
 
version_file = node['gitlab'].key?(service_name) ? "#{@node['gitlab'][service_name]['dir']}/data/PG_VERSION" : "#{@node[service_name]['dir']}/data/PG_VERSION"
version_file = node['gitlab'].key?(node_attribute_key) ? "#{@node['gitlab'][node_attribute_key]['dir']}/data/PG_VERSION" : "#{@node[node_attribute_key]['dir']}/data/PG_VERSION"
PGVersion.new(File.read(version_file).chomp) if File.exist?(version_file)
end
 
Loading
Loading
Loading
Loading
@@ -17,9 +17,9 @@ class GeoPgHelper < BasePgHelper
def connection_info
build_connection_info(
node['gitlab']['geo_secondary']['db_database'],
node['gitlab']['geo-postgresql']['unix_socket_directory'],
node['gitlab']['geo-postgresql']['port'],
node['gitlab']['geo-postgresql']['sql_user']
node['gitlab']['geo_postgresql']['unix_socket_directory'],
node['gitlab']['geo_postgresql']['port'],
node['gitlab']['geo_postgresql']['sql_user']
)
end
end
Loading
Loading
@@ -75,13 +75,13 @@ module Gitlab
note: "Geo does not require Foreign Data Wrapper (FDW) to be configured to replicate data."
},
{
config_keys: %w(gitlab geo-postgresql fdw_external_user),
config_keys: %w(gitlab geo_postgresql fdw_external_user),
deprecation: '13.3',
removal: '14.0', # https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6138
note: "Geo does not require Foreign Data Wrapper (FDW) to be configured to replicate data."
},
{
config_keys: %w(gitlab geo-postgresql fdw_external_password),
config_keys: %w(gitlab geo_postgresql fdw_external_password),
deprecation: '13.3',
removal: '14.0', # https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6138
note: "Geo does not require Foreign Data Wrapper (FDW) to be configured to replicate data."
Loading
Loading
Loading
Loading
@@ -44,6 +44,7 @@ module SettingsDSL
gitlab_kas
geo_secondary
geo_logcursor
geo_postgresql
].freeze
 
def self.extended(base)
Loading
Loading
Loading
Loading
@@ -45,20 +45,21 @@ class PgbouncerHelper < BaseHelper
end
 
def create_pgbouncer_user?(db)
node_attribute_key = SettingsDSL::Utils.sanitized_key(db)
# As part of https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2078 services are
# being split to their own dedicated cookbooks, and attributes are being moved from
# node['gitlab'][service_name] to node[service_name]. Until they've been moved, we
# need to check both.
 
if node['gitlab'].key?(db)
node['gitlab'][db]['enable'] &&
!node['gitlab'][db]['pgbouncer_user'].nil? &&
!node['gitlab'][db]['pgbouncer_user_password'].nil?
if node['gitlab'].key?(node_attribute_key)
node['gitlab'][node_attribute_key]['enable'] &&
!node['gitlab'][node_attribute_key]['pgbouncer_user'].nil? &&
!node['gitlab'][node_attribute_key]['pgbouncer_user_password'].nil?
else
# User info for Patroni are stored under `postgresql` key
info_key = db == 'patroni' ? 'postgresql' : db
info_key = node_attribute_key == 'patroni' ? 'postgresql' : node_attribute_key
 
node[db]['enable'] &&
node[node_attribute_key]['enable'] &&
!node[info_key]['pgbouncer_user'].nil? &&
!node[info_key]['pgbouncer_user_password'].nil?
end
Loading
Loading
Loading
Loading
@@ -24,8 +24,8 @@ auth_query = node['pgbouncer']['auth_query']
if pgb_helper.create_pgbouncer_user?('geo-postgresql')
pgbouncer_user 'geo' do
helper lazy { GeoPgHelper.new(node) }
user node['gitlab']['geo-postgresql']['pgbouncer_user']
password node['gitlab']['geo-postgresql']['pgbouncer_user_password']
user node['gitlab']['geo_postgresql']['pgbouncer_user']
password node['gitlab']['geo_postgresql']['pgbouncer_user_password']
database node['gitlab']['geo_secondary']['db_database']
add_auth_function default_auth_query.eql?(auth_query)
action :create
Loading
Loading
Loading
Loading
@@ -57,7 +57,7 @@ add_command_under_category 'revert-pg-upgrade', 'database',
options[:tmp_dir],
options[:timeout]
)
geo_db_worker.data_dir = File.join(@attributes['gitlab']['geo-postgresql']['dir'], 'data')
geo_db_worker.data_dir = File.join(@attributes['gitlab']['geo_postgresql']['dir'], 'data')
geo_db_worker.tmp_data_dir = "#{geo_db_worker.tmp_dir}/geo-data" unless geo_db_worker.tmp_dir.nil?
geo_db_worker.psql_command = 'gitlab-geo-psql'
end
Loading
Loading
@@ -192,7 +192,7 @@ add_command_under_category 'pg-upgrade', 'database',
unless options[:skip_disk_check]
check_dirs = [@db_worker.tmp_dir]
check_dirs << @db_worker.data_dir if pg_enabled || patroni_enabled
check_dirs << File.join(@attributes['gitlab']['geo-postgresql']['dir'], 'data') if geo_enabled
check_dirs << File.join(@attributes['gitlab']['geo_postgresql']['dir'], 'data') if geo_enabled
 
check_dirs.compact.uniq.each do |dir|
unless GitlabCtl::Util.progress_message(
Loading
Loading
@@ -473,7 +473,7 @@ def geo_pg_upgrade
log('Upgrading the geo-postgresql database')
# Secondary nodes have a replica db under /var/opt/gitlab/postgresql that needs
# the bin files updated and the geo tracking db under /var/opt/gitlab/geo-postgresl that needs data updated
data_dir = File.join(@attributes['gitlab']['geo-postgresql']['dir'], 'data')
data_dir = File.join(@attributes['gitlab']['geo_postgresql']['dir'], 'data')
 
@db_service_name = 'geo-postgresql'
@db_worker.data_dir = data_dir
Loading
Loading
Loading
Loading
@@ -69,7 +69,7 @@ RSpec.describe 'geo postgresql' do
 
context 'when rendering postgresql.conf' do
it 'correctly sets the shared_preload_libraries default setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['shared_preload_libraries']).to be_nil
expect(chef_run.node['gitlab']['geo_postgresql']['shared_preload_libraries']).to be_nil
 
expect(chef_run).to render_file(postgresql_conf)
.with_content(/shared_preload_libraries = ''/)
Loading
Loading
@@ -82,7 +82,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets the max_replication_slots setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['max_replication_slots']).to eq(0)
expect(chef_run.node['gitlab']['geo_postgresql']['max_replication_slots']).to eq(0)
 
expect(chef_run).to render_file(
postgresql_conf
Loading
Loading
@@ -90,7 +90,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets the synchronous_commit setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['synchronous_standby_names']).to eq('')
expect(chef_run.node['gitlab']['geo_postgresql']['synchronous_standby_names']).to eq('')
 
expect(chef_run).to render_file(
postgresql_conf
Loading
Loading
@@ -104,7 +104,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets the max_locks_per_transaction setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['max_locks_per_transaction'])
expect(chef_run.node['gitlab']['geo_postgresql']['max_locks_per_transaction'])
.to eq(128)
 
expect(chef_run).to render_file(
Loading
Loading
@@ -114,7 +114,7 @@ RSpec.describe 'geo postgresql' do
end
context 'when rendering runtime.conf' do
it 'correctly sets the log_line_prefix default setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['log_line_prefix']).to be_nil
expect(chef_run.node['gitlab']['geo_postgresql']['log_line_prefix']).to be_nil
 
expect(chef_run).to render_file(runtime_conf)
.with_content(/log_line_prefix = ''/)
Loading
Loading
@@ -139,7 +139,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets the synchronous_commit setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['synchronous_commit']).to eq('on')
expect(chef_run.node['gitlab']['geo_postgresql']['synchronous_commit']).to eq('on')
 
expect(chef_run).to render_file(
runtime_conf
Loading
Loading
@@ -147,7 +147,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets the hot_standby_feedback setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['hot_standby_feedback'])
expect(chef_run.node['gitlab']['geo_postgresql']['hot_standby_feedback'])
.to eq('off')
 
expect(chef_run).to render_file(
Loading
Loading
@@ -156,7 +156,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets the random_page_cost setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['random_page_cost'])
expect(chef_run.node['gitlab']['geo_postgresql']['random_page_cost'])
.to eq(2.0)
 
expect(chef_run).to render_file(
Loading
Loading
@@ -165,7 +165,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets the log_temp_files setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['log_temp_files'])
expect(chef_run.node['gitlab']['geo_postgresql']['log_temp_files'])
.to eq(-1)
 
expect(chef_run).to render_file(
Loading
Loading
@@ -174,7 +174,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets the log_checkpoints setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['log_checkpoints'])
expect(chef_run.node['gitlab']['geo_postgresql']['log_checkpoints'])
.to eq('off')
 
expect(chef_run).to render_file(
Loading
Loading
@@ -183,7 +183,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets idle_in_transaction_session_timeout' do
expect(chef_run.node['gitlab']['geo-postgresql']['idle_in_transaction_session_timeout'])
expect(chef_run.node['gitlab']['geo_postgresql']['idle_in_transaction_session_timeout'])
.to eq('60000')
 
expect(chef_run).to render_file(runtime_conf)
Loading
Loading
@@ -191,7 +191,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets effective_io_concurrency' do
expect(chef_run.node['gitlab']['geo-postgresql']['effective_io_concurrency'])
expect(chef_run.node['gitlab']['geo_postgresql']['effective_io_concurrency'])
.to eq(1)
 
expect(chef_run).to render_file(runtime_conf)
Loading
Loading
@@ -199,7 +199,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets max_worker_processes' do
expect(chef_run.node['gitlab']['geo-postgresql']['max_worker_processes'])
expect(chef_run.node['gitlab']['geo_postgresql']['max_worker_processes'])
.to eq(8)
 
expect(chef_run).to render_file(runtime_conf)
Loading
Loading
@@ -207,7 +207,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets max_parallel_workers_per_gather' do
expect(chef_run.node['gitlab']['geo-postgresql']['max_parallel_workers_per_gather'])
expect(chef_run.node['gitlab']['geo_postgresql']['max_parallel_workers_per_gather'])
.to eq(0)
 
expect(chef_run).to render_file(runtime_conf)
Loading
Loading
@@ -215,7 +215,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets log_lock_waits' do
expect(chef_run.node['gitlab']['geo-postgresql']['log_lock_waits'])
expect(chef_run.node['gitlab']['geo_postgresql']['log_lock_waits'])
.to eq(1)
 
expect(chef_run).to render_file(runtime_conf)
Loading
Loading
@@ -223,7 +223,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets deadlock_timeout' do
expect(chef_run.node['gitlab']['geo-postgresql']['deadlock_timeout'])
expect(chef_run.node['gitlab']['geo_postgresql']['deadlock_timeout'])
.to eq('5s')
 
expect(chef_run).to render_file(runtime_conf)
Loading
Loading
@@ -231,7 +231,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'sets track_io_timing' do
expect(chef_run.node['gitlab']['geo-postgresql']['track_io_timing'])
expect(chef_run.node['gitlab']['geo_postgresql']['track_io_timing'])
.to eq('off')
 
expect(chef_run).to render_file(runtime_conf)
Loading
Loading
@@ -287,7 +287,7 @@ RSpec.describe 'geo postgresql' do
end
 
it 'correctly sets the shared_preload_libraries setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['shared_preload_libraries']).to eql('pg_stat_statements')
expect(chef_run.node['gitlab']['geo_postgresql']['shared_preload_libraries']).to eql('pg_stat_statements')
 
expect(chef_run).to render_file(postgresql_conf)
.with_content(/shared_preload_libraries = 'pg_stat_statements'/)
Loading
Loading
@@ -308,7 +308,7 @@ RSpec.describe 'geo postgresql' do
 
context 'when rendering runtime.conf' do
it 'correctly sets the log_line_prefix setting' do
expect(chef_run.node['gitlab']['geo-postgresql']['log_line_prefix']).to eql('%a')
expect(chef_run.node['gitlab']['geo_postgresql']['log_line_prefix']).to eql('%a')
 
expect(chef_run).to render_file(runtime_conf)
.with_content(/log_line_prefix = '%a'/)
Loading
Loading
Loading
Loading
@@ -82,7 +82,7 @@ RSpec.describe 'gitlab-ee::geo' do
 
context 'in geo_postgres settings' do
it 'is enabled' do
expect(node['gitlab']['geo-postgresql']['enable']).to eq(true)
expect(node['gitlab']['geo_postgresql']['enable']).to eq(true)
end
end
 
Loading
Loading
Loading
Loading
@@ -40,6 +40,7 @@ RSpec.describe SettingsDSL::Utils do
%w[gitlab-kas gitlab_kas],
%w[geo-secondary geo_secondary],
%w[geo-logcursor geo_logcursor],
%w[geo-postgresql geo_postgresql],
].each do |input, output|
expect(subject.sanitized_key(input)).to eq(output)
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment