Skip to content
Snippets Groups Projects
Commit 5727a017 authored by Ian Baum's avatar Ian Baum
Browse files

Merge branch 'nhxnguyen-legacy-attributes' into 'master'

Address TODOs for removing legacy attribute support

See merge request gitlab-org/omnibus-gitlab!4533
parents e3616db9 92f5e54f
No related branches found
No related tags found
No related merge requests found
Showing with 26 additions and 71 deletions
---
title: 'Address TODOs for removing legacy attribute support'
merge_request: 4533
author:
type: other
Loading
Loading
@@ -475,5 +475,5 @@ max_locks_per_transaction = <%= @max_locks_per_transaction %> # min 10
 
include 'runtime.conf'
<% if @geo_secondary_enabled %>
include_if_exists 'gitlab-geo.conf'
include_if_exists 'gitlab-geo.conf'
<% end %>
Loading
Loading
@@ -77,12 +77,7 @@ class RepmgrHandler
end
 
def postgresql_directory
# We still need to support legacy attributes starting with `gitlab`, as they might exists before running
# configure on an existing installation
#
# TODO: Remove support for legacy attributes in GitLab 13.0
node_attributes.dig('gitlab', 'postgresql', 'dir') ||
node_attributes.dig('postgresql', 'dir')
node_attributes.dig('postgresql', 'dir')
end
 
def execute_psql(options)
Loading
Loading
@@ -193,12 +188,7 @@ class RepmgrHandler
private
 
def postgresql_data_dir
# We still need to support legacy attributes starting with `gitlab`, as they might exists before running
# configure on an existing installation
#
# TODO: Remove support for legacy attributes in GitLab 13.0
node_attributes.dig('gitlab', 'postgresql', 'data_dir') ||
node_attributes.dig('postgresql', 'data_dir')
node_attributes.dig('postgresql', 'data_dir')
end
end
end
Loading
Loading
Loading
Loading
@@ -14,12 +14,7 @@ add_command_under_category('repmgr', 'database', 'Manage repmgr PostgreSQL clust
# know the primary node
repmgr_options = RepmgrHandler.parse_options(ARGV)
 
# We still need to support legacy attributes starting with `gitlab`, as they might exists before running
# configure on an existing installation
#
# TODO: Remove support for legacy attributes in GitLab 13.0
postgresql_directory = node_attributes.dig('gitlab', 'postgresql', 'data_dir') ||
node_attributes.dig('postgresql', 'data_dir')
postgresql_directory = node_attributes.dig('postgresql', 'data_dir')
 
repmgr_args = begin
{
Loading
Loading
Loading
Loading
@@ -70,11 +70,7 @@ module GitlabCtl
end
 
def run_pg_command(command)
# We still need to support legacy attributes starting with `gitlab`, as they might exists before running
# configure on an existing installation
#
# TODO: Remove support for legacy attributes in GitLab 13.0
pg_username = node_attributes.dig(:gitlab, :postgresql, :username) || node_attributes.dig(:postgresql, :username)
pg_username = node_attributes.dig(:postgresql, :username)
 
GitlabCtl::Util.get_command_output("su - #{pg_username} -c \"#{command}\"", nil, @timeout)
end
Loading
Loading
Loading
Loading
@@ -28,12 +28,7 @@ module GitlabCtl
 
def postgresql_username
node_attributes = GitlabCtl::Util.get_node_attributes
# We still need to support legacy attributes starting with `gitlab`, as they might exists before running
# configure on an existing installation
#
# TODO: Remove support for legacy attributes in GitLab 13.0
(node_attributes.dig('gitlab', 'postgresql', 'username') || node_attributes.dig('postgresql', 'username')).to_s
node_attributes.dig('postgresql', 'username').to_s
end
 
def postgresql_group
Loading
Loading
Loading
Loading
@@ -39,12 +39,7 @@ class PostgreSQL
end
 
def replication_user
# We still need to support legacy attributes starting with `gitlab`, as they might exists before running
# configure on an existing installation
#
# TODO: Remove support for legacy attributes in GitLab 13.0
configured_user = (node_attributes.dig('gitlab', 'postgresql', 'sql_replication_user') ||
node_attributes.dig('postgresql', 'sql_replication_user')).to_s
configured_user = node_attributes.dig('postgresql', 'sql_replication_user').to_s
 
configured_user.tap do |user|
raise ArgumentError, 'Replication user not defined in `sql_replication_user`!' if user.strip.empty?
Loading
Loading
Loading
Loading
@@ -212,7 +212,7 @@ RSpec.describe 'gitlab-ee::geo-secondary' do
end
end
 
describe 'PostgreSQL gitlab-geo.conf', focus: true do
describe 'PostgreSQL gitlab-geo.conf' do
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab-ee::default') }
let(:geo_conf) { '/var/opt/gitlab/postgresql/data/gitlab-geo.conf' }
let(:postgresql_conf) { '/var/opt/gitlab/postgresql/data/postgresql.conf' }
Loading
Loading
Loading
Loading
@@ -127,7 +127,7 @@ RSpec.describe 'patroni cookbook' do
expect(chef_run).not_to run_execute(/(start|reload) postgresql/)
end
 
it 'should create database objects (roles, databses, extension)', focus: true do
it 'should create database objects (roles, databses, extension)' do
expect(chef_run).not_to run_execute('/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8')
expect(chef_run).to create_postgresql_user('gitlab')
expect(chef_run).to create_postgresql_user('gitlab_replicator')
Loading
Loading
Loading
Loading
@@ -29,10 +29,8 @@ RSpec.describe GitlabCtl::PgUpgrade do
allow(GitlabCtl::Util).to receive(:parse_json_file).and_return(
{
'default' => {
'gitlab' => {
'postgresql' => {
'username' => 'arbitrary-user-name'
}
'postgresql' => {
'username' => 'arbitrary-user-name'
}
}
})
Loading
Loading
Loading
Loading
@@ -5,37 +5,18 @@ $LOAD_PATH << File.join(__dir__, '../../../files/gitlab-ctl-commands/lib')
require 'postgresql'
 
RSpec.describe GitlabCtl::PostgreSQL do
describe "#postgresql_usernamename" do
context 'when using legacy configuration' do
before do
allow(GitlabCtl::Util).to receive(:get_node_attributes).and_return(
{
'gitlab' => {
'postgresql' => {
'username' => 'foo'
}
}
describe "#postgresql_username" do
before do
allow(GitlabCtl::Util).to receive(:get_node_attributes).and_return(
{
'postgresql' => {
'username' => 'bar'
}
)
end
it 'detects username correctly' do
expect(described_class.postgresql_username).to eq('foo')
end
}
)
end
context 'when using new configuration' do
before do
allow(GitlabCtl::Util).to receive(:get_node_attributes).and_return(
{
'postgresql' => {
'username' => 'bar'
}
}
)
end
it 'detects username correctly' do
expect(described_class.postgresql_username).to eq('bar')
end
it 'detects username correctly' do
expect(described_class.postgresql_username).to eq('bar')
end
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